target
stringlengths 20
113k
| src_fm
stringlengths 11
86.3k
| src_fm_fc
stringlengths 21
86.4k
| src_fm_fc_co
stringlengths 30
86.4k
| src_fm_fc_ms
stringlengths 42
86.8k
| src_fm_fc_ms_ff
stringlengths 43
86.8k
|
---|---|---|---|---|---|
@Test void mapProofWithAbsentKeyShouldBeCorrect() { DbKey firstDbKey = DbKeyTestUtils.branchKeyFromPrefix("101100"); ByteString valueKey = DbKeyTestUtils.keyByteStringFromString("101110"); byte[] absentKey = DbKeyTestUtils.keyFromString("101111"); UncheckedMapProof uncheckedFlatMapProof = new UncheckedFlatMapProof( singletonList(createMapProofEntry(firstDbKey)), singletonList(createMapEntry(valueKey, FIRST_VALUE)), singletonList(absentKey)); CheckedMapProof checkedMapProof = uncheckedFlatMapProof.check(); assertThat(checkedMapProof.getProofStatus(), equalTo(MapProofStatus.CORRECT)); }
|
@Override public CheckedMapProof check() { MapProofStatus orderCheckResult = orderCheck(); if (orderCheckResult != MapProofStatus.CORRECT) { return CheckedFlatMapProof.invalid(orderCheckResult); } if (containsInvalidHashes()) { return CheckedFlatMapProof.invalid(MapProofStatus.INVALID_HASH_SIZE); } if (prefixesIncluded()) { return CheckedFlatMapProof.invalid(MapProofStatus.EMBEDDED_PATH); } if (isEmptyProof()) { return checkEmptyProof(); } else if (isSingletonProof()) { return checkSingletonProof(); } else { return checkProof(); } }
|
UncheckedFlatMapProof implements UncheckedMapProof { @Override public CheckedMapProof check() { MapProofStatus orderCheckResult = orderCheck(); if (orderCheckResult != MapProofStatus.CORRECT) { return CheckedFlatMapProof.invalid(orderCheckResult); } if (containsInvalidHashes()) { return CheckedFlatMapProof.invalid(MapProofStatus.INVALID_HASH_SIZE); } if (prefixesIncluded()) { return CheckedFlatMapProof.invalid(MapProofStatus.EMBEDDED_PATH); } if (isEmptyProof()) { return checkEmptyProof(); } else if (isSingletonProof()) { return checkSingletonProof(); } else { return checkProof(); } } }
|
UncheckedFlatMapProof implements UncheckedMapProof { @Override public CheckedMapProof check() { MapProofStatus orderCheckResult = orderCheck(); if (orderCheckResult != MapProofStatus.CORRECT) { return CheckedFlatMapProof.invalid(orderCheckResult); } if (containsInvalidHashes()) { return CheckedFlatMapProof.invalid(MapProofStatus.INVALID_HASH_SIZE); } if (prefixesIncluded()) { return CheckedFlatMapProof.invalid(MapProofStatus.EMBEDDED_PATH); } if (isEmptyProof()) { return checkEmptyProof(); } else if (isSingletonProof()) { return checkSingletonProof(); } else { return checkProof(); } } UncheckedFlatMapProof(
List<MapProofEntry> proof,
List<MapEntry<ByteString, ByteString>> entries,
List<byte[]> missingKeys); }
|
UncheckedFlatMapProof implements UncheckedMapProof { @Override public CheckedMapProof check() { MapProofStatus orderCheckResult = orderCheck(); if (orderCheckResult != MapProofStatus.CORRECT) { return CheckedFlatMapProof.invalid(orderCheckResult); } if (containsInvalidHashes()) { return CheckedFlatMapProof.invalid(MapProofStatus.INVALID_HASH_SIZE); } if (prefixesIncluded()) { return CheckedFlatMapProof.invalid(MapProofStatus.EMBEDDED_PATH); } if (isEmptyProof()) { return checkEmptyProof(); } else if (isSingletonProof()) { return checkSingletonProof(); } else { return checkProof(); } } UncheckedFlatMapProof(
List<MapProofEntry> proof,
List<MapEntry<ByteString, ByteString>> entries,
List<byte[]> missingKeys); @Override CheckedMapProof check(); }
|
UncheckedFlatMapProof implements UncheckedMapProof { @Override public CheckedMapProof check() { MapProofStatus orderCheckResult = orderCheck(); if (orderCheckResult != MapProofStatus.CORRECT) { return CheckedFlatMapProof.invalid(orderCheckResult); } if (containsInvalidHashes()) { return CheckedFlatMapProof.invalid(MapProofStatus.INVALID_HASH_SIZE); } if (prefixesIncluded()) { return CheckedFlatMapProof.invalid(MapProofStatus.EMBEDDED_PATH); } if (isEmptyProof()) { return checkEmptyProof(); } else if (isSingletonProof()) { return checkSingletonProof(); } else { return checkProof(); } } UncheckedFlatMapProof(
List<MapProofEntry> proof,
List<MapEntry<ByteString, ByteString>> entries,
List<byte[]> missingKeys); @Override CheckedMapProof check(); }
|
@Test void indexOfNoMatches() { List<Integer> l = ImmutableList.of(-1, -2, -3); Predicate<Integer> positiveInt = i -> i > 0; assertThat(ExonumIterables.indexOf(l, positiveInt), equalTo(OptionalInt.empty())); }
|
static <T> OptionalInt indexOf(Iterable<T> list, Predicate<? super T> p) { int i = Iterables.indexOf(list, p::test); if (i == -1) { return OptionalInt.empty(); } return OptionalInt.of(i); }
|
ExonumIterables { static <T> OptionalInt indexOf(Iterable<T> list, Predicate<? super T> p) { int i = Iterables.indexOf(list, p::test); if (i == -1) { return OptionalInt.empty(); } return OptionalInt.of(i); } }
|
ExonumIterables { static <T> OptionalInt indexOf(Iterable<T> list, Predicate<? super T> p) { int i = Iterables.indexOf(list, p::test); if (i == -1) { return OptionalInt.empty(); } return OptionalInt.of(i); } private ExonumIterables(); }
|
ExonumIterables { static <T> OptionalInt indexOf(Iterable<T> list, Predicate<? super T> p) { int i = Iterables.indexOf(list, p::test); if (i == -1) { return OptionalInt.empty(); } return OptionalInt.of(i); } private ExonumIterables(); }
|
ExonumIterables { static <T> OptionalInt indexOf(Iterable<T> list, Predicate<? super T> p) { int i = Iterables.indexOf(list, p::test); if (i == -1) { return OptionalInt.empty(); } return OptionalInt.of(i); } private ExonumIterables(); }
|
@Test void mapProofWithInvalidOrderShouldBeIncorrect() { DbKey firstDbKey = DbKeyTestUtils.branchKeyFromPrefix("10"); DbKey secondDbKey = DbKeyTestUtils.branchKeyFromPrefix("01"); UncheckedMapProof uncheckedFlatMapProof = new UncheckedFlatMapProof( Arrays.asList(createMapProofEntry(firstDbKey), createMapProofEntry(secondDbKey)), emptyList(), emptyList()); CheckedMapProof checkedMapProof = uncheckedFlatMapProof.check(); assertThat(checkedMapProof.getProofStatus(), equalTo(MapProofStatus.INVALID_ORDER)); }
|
@Override public CheckedMapProof check() { MapProofStatus orderCheckResult = orderCheck(); if (orderCheckResult != MapProofStatus.CORRECT) { return CheckedFlatMapProof.invalid(orderCheckResult); } if (containsInvalidHashes()) { return CheckedFlatMapProof.invalid(MapProofStatus.INVALID_HASH_SIZE); } if (prefixesIncluded()) { return CheckedFlatMapProof.invalid(MapProofStatus.EMBEDDED_PATH); } if (isEmptyProof()) { return checkEmptyProof(); } else if (isSingletonProof()) { return checkSingletonProof(); } else { return checkProof(); } }
|
UncheckedFlatMapProof implements UncheckedMapProof { @Override public CheckedMapProof check() { MapProofStatus orderCheckResult = orderCheck(); if (orderCheckResult != MapProofStatus.CORRECT) { return CheckedFlatMapProof.invalid(orderCheckResult); } if (containsInvalidHashes()) { return CheckedFlatMapProof.invalid(MapProofStatus.INVALID_HASH_SIZE); } if (prefixesIncluded()) { return CheckedFlatMapProof.invalid(MapProofStatus.EMBEDDED_PATH); } if (isEmptyProof()) { return checkEmptyProof(); } else if (isSingletonProof()) { return checkSingletonProof(); } else { return checkProof(); } } }
|
UncheckedFlatMapProof implements UncheckedMapProof { @Override public CheckedMapProof check() { MapProofStatus orderCheckResult = orderCheck(); if (orderCheckResult != MapProofStatus.CORRECT) { return CheckedFlatMapProof.invalid(orderCheckResult); } if (containsInvalidHashes()) { return CheckedFlatMapProof.invalid(MapProofStatus.INVALID_HASH_SIZE); } if (prefixesIncluded()) { return CheckedFlatMapProof.invalid(MapProofStatus.EMBEDDED_PATH); } if (isEmptyProof()) { return checkEmptyProof(); } else if (isSingletonProof()) { return checkSingletonProof(); } else { return checkProof(); } } UncheckedFlatMapProof(
List<MapProofEntry> proof,
List<MapEntry<ByteString, ByteString>> entries,
List<byte[]> missingKeys); }
|
UncheckedFlatMapProof implements UncheckedMapProof { @Override public CheckedMapProof check() { MapProofStatus orderCheckResult = orderCheck(); if (orderCheckResult != MapProofStatus.CORRECT) { return CheckedFlatMapProof.invalid(orderCheckResult); } if (containsInvalidHashes()) { return CheckedFlatMapProof.invalid(MapProofStatus.INVALID_HASH_SIZE); } if (prefixesIncluded()) { return CheckedFlatMapProof.invalid(MapProofStatus.EMBEDDED_PATH); } if (isEmptyProof()) { return checkEmptyProof(); } else if (isSingletonProof()) { return checkSingletonProof(); } else { return checkProof(); } } UncheckedFlatMapProof(
List<MapProofEntry> proof,
List<MapEntry<ByteString, ByteString>> entries,
List<byte[]> missingKeys); @Override CheckedMapProof check(); }
|
UncheckedFlatMapProof implements UncheckedMapProof { @Override public CheckedMapProof check() { MapProofStatus orderCheckResult = orderCheck(); if (orderCheckResult != MapProofStatus.CORRECT) { return CheckedFlatMapProof.invalid(orderCheckResult); } if (containsInvalidHashes()) { return CheckedFlatMapProof.invalid(MapProofStatus.INVALID_HASH_SIZE); } if (prefixesIncluded()) { return CheckedFlatMapProof.invalid(MapProofStatus.EMBEDDED_PATH); } if (isEmptyProof()) { return checkEmptyProof(); } else if (isSingletonProof()) { return checkSingletonProof(); } else { return checkProof(); } } UncheckedFlatMapProof(
List<MapProofEntry> proof,
List<MapEntry<ByteString, ByteString>> entries,
List<byte[]> missingKeys); @Override CheckedMapProof check(); }
|
@Test void mapProofWithSingleBranchProofEntryShouldBeInvalid() { DbKey firstDbKey = DbKeyTestUtils.branchKeyFromPrefix("1011111"); byte[] absentKey = DbKeyTestUtils.keyFromString("101111"); UncheckedMapProof uncheckedFlatMapProof = new UncheckedFlatMapProof( singletonList(createMapProofEntry(firstDbKey)), emptyList(), singletonList(absentKey)); CheckedMapProof checkedMapProof = uncheckedFlatMapProof.check(); assertThat(checkedMapProof.getProofStatus(), equalTo(MapProofStatus.NON_TERMINAL_NODE)); }
|
@Override public CheckedMapProof check() { MapProofStatus orderCheckResult = orderCheck(); if (orderCheckResult != MapProofStatus.CORRECT) { return CheckedFlatMapProof.invalid(orderCheckResult); } if (containsInvalidHashes()) { return CheckedFlatMapProof.invalid(MapProofStatus.INVALID_HASH_SIZE); } if (prefixesIncluded()) { return CheckedFlatMapProof.invalid(MapProofStatus.EMBEDDED_PATH); } if (isEmptyProof()) { return checkEmptyProof(); } else if (isSingletonProof()) { return checkSingletonProof(); } else { return checkProof(); } }
|
UncheckedFlatMapProof implements UncheckedMapProof { @Override public CheckedMapProof check() { MapProofStatus orderCheckResult = orderCheck(); if (orderCheckResult != MapProofStatus.CORRECT) { return CheckedFlatMapProof.invalid(orderCheckResult); } if (containsInvalidHashes()) { return CheckedFlatMapProof.invalid(MapProofStatus.INVALID_HASH_SIZE); } if (prefixesIncluded()) { return CheckedFlatMapProof.invalid(MapProofStatus.EMBEDDED_PATH); } if (isEmptyProof()) { return checkEmptyProof(); } else if (isSingletonProof()) { return checkSingletonProof(); } else { return checkProof(); } } }
|
UncheckedFlatMapProof implements UncheckedMapProof { @Override public CheckedMapProof check() { MapProofStatus orderCheckResult = orderCheck(); if (orderCheckResult != MapProofStatus.CORRECT) { return CheckedFlatMapProof.invalid(orderCheckResult); } if (containsInvalidHashes()) { return CheckedFlatMapProof.invalid(MapProofStatus.INVALID_HASH_SIZE); } if (prefixesIncluded()) { return CheckedFlatMapProof.invalid(MapProofStatus.EMBEDDED_PATH); } if (isEmptyProof()) { return checkEmptyProof(); } else if (isSingletonProof()) { return checkSingletonProof(); } else { return checkProof(); } } UncheckedFlatMapProof(
List<MapProofEntry> proof,
List<MapEntry<ByteString, ByteString>> entries,
List<byte[]> missingKeys); }
|
UncheckedFlatMapProof implements UncheckedMapProof { @Override public CheckedMapProof check() { MapProofStatus orderCheckResult = orderCheck(); if (orderCheckResult != MapProofStatus.CORRECT) { return CheckedFlatMapProof.invalid(orderCheckResult); } if (containsInvalidHashes()) { return CheckedFlatMapProof.invalid(MapProofStatus.INVALID_HASH_SIZE); } if (prefixesIncluded()) { return CheckedFlatMapProof.invalid(MapProofStatus.EMBEDDED_PATH); } if (isEmptyProof()) { return checkEmptyProof(); } else if (isSingletonProof()) { return checkSingletonProof(); } else { return checkProof(); } } UncheckedFlatMapProof(
List<MapProofEntry> proof,
List<MapEntry<ByteString, ByteString>> entries,
List<byte[]> missingKeys); @Override CheckedMapProof check(); }
|
UncheckedFlatMapProof implements UncheckedMapProof { @Override public CheckedMapProof check() { MapProofStatus orderCheckResult = orderCheck(); if (orderCheckResult != MapProofStatus.CORRECT) { return CheckedFlatMapProof.invalid(orderCheckResult); } if (containsInvalidHashes()) { return CheckedFlatMapProof.invalid(MapProofStatus.INVALID_HASH_SIZE); } if (prefixesIncluded()) { return CheckedFlatMapProof.invalid(MapProofStatus.EMBEDDED_PATH); } if (isEmptyProof()) { return checkEmptyProof(); } else if (isSingletonProof()) { return checkSingletonProof(); } else { return checkProof(); } } UncheckedFlatMapProof(
List<MapProofEntry> proof,
List<MapEntry<ByteString, ByteString>> entries,
List<byte[]> missingKeys); @Override CheckedMapProof check(); }
|
@Test void mapProofWithSingleLeafProofEntryShouldBeCorrect() { DbKey firstDbKey = DbKeyTestUtils.leafKeyFromPrefix("1011111"); byte[] absentKey = DbKeyTestUtils.keyFromString("101111"); UncheckedMapProof uncheckedFlatMapProof = new UncheckedFlatMapProof( singletonList(createMapProofEntry(firstDbKey)), emptyList(), singletonList(absentKey)); CheckedMapProof checkedMapProof = uncheckedFlatMapProof.check(); assertThat(checkedMapProof.getProofStatus(), equalTo(MapProofStatus.CORRECT)); }
|
@Override public CheckedMapProof check() { MapProofStatus orderCheckResult = orderCheck(); if (orderCheckResult != MapProofStatus.CORRECT) { return CheckedFlatMapProof.invalid(orderCheckResult); } if (containsInvalidHashes()) { return CheckedFlatMapProof.invalid(MapProofStatus.INVALID_HASH_SIZE); } if (prefixesIncluded()) { return CheckedFlatMapProof.invalid(MapProofStatus.EMBEDDED_PATH); } if (isEmptyProof()) { return checkEmptyProof(); } else if (isSingletonProof()) { return checkSingletonProof(); } else { return checkProof(); } }
|
UncheckedFlatMapProof implements UncheckedMapProof { @Override public CheckedMapProof check() { MapProofStatus orderCheckResult = orderCheck(); if (orderCheckResult != MapProofStatus.CORRECT) { return CheckedFlatMapProof.invalid(orderCheckResult); } if (containsInvalidHashes()) { return CheckedFlatMapProof.invalid(MapProofStatus.INVALID_HASH_SIZE); } if (prefixesIncluded()) { return CheckedFlatMapProof.invalid(MapProofStatus.EMBEDDED_PATH); } if (isEmptyProof()) { return checkEmptyProof(); } else if (isSingletonProof()) { return checkSingletonProof(); } else { return checkProof(); } } }
|
UncheckedFlatMapProof implements UncheckedMapProof { @Override public CheckedMapProof check() { MapProofStatus orderCheckResult = orderCheck(); if (orderCheckResult != MapProofStatus.CORRECT) { return CheckedFlatMapProof.invalid(orderCheckResult); } if (containsInvalidHashes()) { return CheckedFlatMapProof.invalid(MapProofStatus.INVALID_HASH_SIZE); } if (prefixesIncluded()) { return CheckedFlatMapProof.invalid(MapProofStatus.EMBEDDED_PATH); } if (isEmptyProof()) { return checkEmptyProof(); } else if (isSingletonProof()) { return checkSingletonProof(); } else { return checkProof(); } } UncheckedFlatMapProof(
List<MapProofEntry> proof,
List<MapEntry<ByteString, ByteString>> entries,
List<byte[]> missingKeys); }
|
UncheckedFlatMapProof implements UncheckedMapProof { @Override public CheckedMapProof check() { MapProofStatus orderCheckResult = orderCheck(); if (orderCheckResult != MapProofStatus.CORRECT) { return CheckedFlatMapProof.invalid(orderCheckResult); } if (containsInvalidHashes()) { return CheckedFlatMapProof.invalid(MapProofStatus.INVALID_HASH_SIZE); } if (prefixesIncluded()) { return CheckedFlatMapProof.invalid(MapProofStatus.EMBEDDED_PATH); } if (isEmptyProof()) { return checkEmptyProof(); } else if (isSingletonProof()) { return checkSingletonProof(); } else { return checkProof(); } } UncheckedFlatMapProof(
List<MapProofEntry> proof,
List<MapEntry<ByteString, ByteString>> entries,
List<byte[]> missingKeys); @Override CheckedMapProof check(); }
|
UncheckedFlatMapProof implements UncheckedMapProof { @Override public CheckedMapProof check() { MapProofStatus orderCheckResult = orderCheck(); if (orderCheckResult != MapProofStatus.CORRECT) { return CheckedFlatMapProof.invalid(orderCheckResult); } if (containsInvalidHashes()) { return CheckedFlatMapProof.invalid(MapProofStatus.INVALID_HASH_SIZE); } if (prefixesIncluded()) { return CheckedFlatMapProof.invalid(MapProofStatus.EMBEDDED_PATH); } if (isEmptyProof()) { return checkEmptyProof(); } else if (isSingletonProof()) { return checkSingletonProof(); } else { return checkProof(); } } UncheckedFlatMapProof(
List<MapProofEntry> proof,
List<MapEntry<ByteString, ByteString>> entries,
List<byte[]> missingKeys); @Override CheckedMapProof check(); }
|
@Test void mapProofWithIncludedPrefixesShouldBeInvalid() { DbKey firstDbKey = DbKeyTestUtils.branchKeyFromPrefix("01"); DbKey secondDbKey = DbKeyTestUtils.branchKeyFromPrefix("11"); byte[] absentKey = DbKeyTestUtils.keyFromString("111111"); UncheckedMapProof uncheckedFlatMapProof = new UncheckedFlatMapProof( Arrays.asList( createMapProofEntry(firstDbKey), createMapProofEntry(secondDbKey)), emptyList(), singletonList(absentKey)); CheckedMapProof checkedMapProof = uncheckedFlatMapProof.check(); assertThat(checkedMapProof.getProofStatus(), equalTo(MapProofStatus.EMBEDDED_PATH)); }
|
@Override public CheckedMapProof check() { MapProofStatus orderCheckResult = orderCheck(); if (orderCheckResult != MapProofStatus.CORRECT) { return CheckedFlatMapProof.invalid(orderCheckResult); } if (containsInvalidHashes()) { return CheckedFlatMapProof.invalid(MapProofStatus.INVALID_HASH_SIZE); } if (prefixesIncluded()) { return CheckedFlatMapProof.invalid(MapProofStatus.EMBEDDED_PATH); } if (isEmptyProof()) { return checkEmptyProof(); } else if (isSingletonProof()) { return checkSingletonProof(); } else { return checkProof(); } }
|
UncheckedFlatMapProof implements UncheckedMapProof { @Override public CheckedMapProof check() { MapProofStatus orderCheckResult = orderCheck(); if (orderCheckResult != MapProofStatus.CORRECT) { return CheckedFlatMapProof.invalid(orderCheckResult); } if (containsInvalidHashes()) { return CheckedFlatMapProof.invalid(MapProofStatus.INVALID_HASH_SIZE); } if (prefixesIncluded()) { return CheckedFlatMapProof.invalid(MapProofStatus.EMBEDDED_PATH); } if (isEmptyProof()) { return checkEmptyProof(); } else if (isSingletonProof()) { return checkSingletonProof(); } else { return checkProof(); } } }
|
UncheckedFlatMapProof implements UncheckedMapProof { @Override public CheckedMapProof check() { MapProofStatus orderCheckResult = orderCheck(); if (orderCheckResult != MapProofStatus.CORRECT) { return CheckedFlatMapProof.invalid(orderCheckResult); } if (containsInvalidHashes()) { return CheckedFlatMapProof.invalid(MapProofStatus.INVALID_HASH_SIZE); } if (prefixesIncluded()) { return CheckedFlatMapProof.invalid(MapProofStatus.EMBEDDED_PATH); } if (isEmptyProof()) { return checkEmptyProof(); } else if (isSingletonProof()) { return checkSingletonProof(); } else { return checkProof(); } } UncheckedFlatMapProof(
List<MapProofEntry> proof,
List<MapEntry<ByteString, ByteString>> entries,
List<byte[]> missingKeys); }
|
UncheckedFlatMapProof implements UncheckedMapProof { @Override public CheckedMapProof check() { MapProofStatus orderCheckResult = orderCheck(); if (orderCheckResult != MapProofStatus.CORRECT) { return CheckedFlatMapProof.invalid(orderCheckResult); } if (containsInvalidHashes()) { return CheckedFlatMapProof.invalid(MapProofStatus.INVALID_HASH_SIZE); } if (prefixesIncluded()) { return CheckedFlatMapProof.invalid(MapProofStatus.EMBEDDED_PATH); } if (isEmptyProof()) { return checkEmptyProof(); } else if (isSingletonProof()) { return checkSingletonProof(); } else { return checkProof(); } } UncheckedFlatMapProof(
List<MapProofEntry> proof,
List<MapEntry<ByteString, ByteString>> entries,
List<byte[]> missingKeys); @Override CheckedMapProof check(); }
|
UncheckedFlatMapProof implements UncheckedMapProof { @Override public CheckedMapProof check() { MapProofStatus orderCheckResult = orderCheck(); if (orderCheckResult != MapProofStatus.CORRECT) { return CheckedFlatMapProof.invalid(orderCheckResult); } if (containsInvalidHashes()) { return CheckedFlatMapProof.invalid(MapProofStatus.INVALID_HASH_SIZE); } if (prefixesIncluded()) { return CheckedFlatMapProof.invalid(MapProofStatus.EMBEDDED_PATH); } if (isEmptyProof()) { return checkEmptyProof(); } else if (isSingletonProof()) { return checkSingletonProof(); } else { return checkProof(); } } UncheckedFlatMapProof(
List<MapProofEntry> proof,
List<MapEntry<ByteString, ByteString>> entries,
List<byte[]> missingKeys); @Override CheckedMapProof check(); }
|
@Test void mapProofWithIncludedBranchPrefixesShouldBeInvalid() { DbKey firstDbKey = DbKeyTestUtils.branchKeyFromPrefix("01"); DbKey secondDbKey = DbKeyTestUtils.branchKeyFromPrefix("011"); byte[] absentKey = DbKeyTestUtils.keyFromString("111111"); UncheckedMapProof uncheckedFlatMapProof = new UncheckedFlatMapProof( Arrays.asList( createMapProofEntry(firstDbKey), createMapProofEntry(secondDbKey)), emptyList(), singletonList(absentKey)); CheckedMapProof checkedMapProof = uncheckedFlatMapProof.check(); assertThat(checkedMapProof.getProofStatus(), equalTo(MapProofStatus.EMBEDDED_PATH)); }
|
@Override public CheckedMapProof check() { MapProofStatus orderCheckResult = orderCheck(); if (orderCheckResult != MapProofStatus.CORRECT) { return CheckedFlatMapProof.invalid(orderCheckResult); } if (containsInvalidHashes()) { return CheckedFlatMapProof.invalid(MapProofStatus.INVALID_HASH_SIZE); } if (prefixesIncluded()) { return CheckedFlatMapProof.invalid(MapProofStatus.EMBEDDED_PATH); } if (isEmptyProof()) { return checkEmptyProof(); } else if (isSingletonProof()) { return checkSingletonProof(); } else { return checkProof(); } }
|
UncheckedFlatMapProof implements UncheckedMapProof { @Override public CheckedMapProof check() { MapProofStatus orderCheckResult = orderCheck(); if (orderCheckResult != MapProofStatus.CORRECT) { return CheckedFlatMapProof.invalid(orderCheckResult); } if (containsInvalidHashes()) { return CheckedFlatMapProof.invalid(MapProofStatus.INVALID_HASH_SIZE); } if (prefixesIncluded()) { return CheckedFlatMapProof.invalid(MapProofStatus.EMBEDDED_PATH); } if (isEmptyProof()) { return checkEmptyProof(); } else if (isSingletonProof()) { return checkSingletonProof(); } else { return checkProof(); } } }
|
UncheckedFlatMapProof implements UncheckedMapProof { @Override public CheckedMapProof check() { MapProofStatus orderCheckResult = orderCheck(); if (orderCheckResult != MapProofStatus.CORRECT) { return CheckedFlatMapProof.invalid(orderCheckResult); } if (containsInvalidHashes()) { return CheckedFlatMapProof.invalid(MapProofStatus.INVALID_HASH_SIZE); } if (prefixesIncluded()) { return CheckedFlatMapProof.invalid(MapProofStatus.EMBEDDED_PATH); } if (isEmptyProof()) { return checkEmptyProof(); } else if (isSingletonProof()) { return checkSingletonProof(); } else { return checkProof(); } } UncheckedFlatMapProof(
List<MapProofEntry> proof,
List<MapEntry<ByteString, ByteString>> entries,
List<byte[]> missingKeys); }
|
UncheckedFlatMapProof implements UncheckedMapProof { @Override public CheckedMapProof check() { MapProofStatus orderCheckResult = orderCheck(); if (orderCheckResult != MapProofStatus.CORRECT) { return CheckedFlatMapProof.invalid(orderCheckResult); } if (containsInvalidHashes()) { return CheckedFlatMapProof.invalid(MapProofStatus.INVALID_HASH_SIZE); } if (prefixesIncluded()) { return CheckedFlatMapProof.invalid(MapProofStatus.EMBEDDED_PATH); } if (isEmptyProof()) { return checkEmptyProof(); } else if (isSingletonProof()) { return checkSingletonProof(); } else { return checkProof(); } } UncheckedFlatMapProof(
List<MapProofEntry> proof,
List<MapEntry<ByteString, ByteString>> entries,
List<byte[]> missingKeys); @Override CheckedMapProof check(); }
|
UncheckedFlatMapProof implements UncheckedMapProof { @Override public CheckedMapProof check() { MapProofStatus orderCheckResult = orderCheck(); if (orderCheckResult != MapProofStatus.CORRECT) { return CheckedFlatMapProof.invalid(orderCheckResult); } if (containsInvalidHashes()) { return CheckedFlatMapProof.invalid(MapProofStatus.INVALID_HASH_SIZE); } if (prefixesIncluded()) { return CheckedFlatMapProof.invalid(MapProofStatus.EMBEDDED_PATH); } if (isEmptyProof()) { return checkEmptyProof(); } else if (isSingletonProof()) { return checkSingletonProof(); } else { return checkProof(); } } UncheckedFlatMapProof(
List<MapProofEntry> proof,
List<MapEntry<ByteString, ByteString>> entries,
List<byte[]> missingKeys); @Override CheckedMapProof check(); }
|
@Test void testExhaustive() { List<Hasher> hashers = ImmutableList.of( new StreamingVersion().newHasher(), new StreamingVersion().newHasher(52), new NonStreamingVersion().newHasher(), new NonStreamingVersion().newHasher(123)); Random random = new Random(0); for (int i = 0; i < 200; i++) { RandomHasherAction.pickAtRandom(random).performAction(random, hashers); } HashCode[] codes = new HashCode[hashers.size()]; for (int i = 0; i < hashers.size(); i++) { codes[i] = hashers.get(i).hash(); } for (int i = 1; i < codes.length; i++) { assertEquals(codes[i - 1], codes[i]); } }
|
@Override public Hasher newHasher() { return newHasher(32); }
|
AbstractNonStreamingHashFunction extends AbstractHashFunction { @Override public Hasher newHasher() { return newHasher(32); } }
|
AbstractNonStreamingHashFunction extends AbstractHashFunction { @Override public Hasher newHasher() { return newHasher(32); } }
|
AbstractNonStreamingHashFunction extends AbstractHashFunction { @Override public Hasher newHasher() { return newHasher(32); } @Override Hasher newHasher(); @Override Hasher newHasher(int expectedInputSize); @Override HashCode hashInt(int input); @Override HashCode hashLong(long input); @Override HashCode hashUnencodedChars(CharSequence input); @Override HashCode hashString(CharSequence input, Charset charset); @Override abstract HashCode hashBytes(byte[] input, int off, int len); @Override HashCode hashBytes(ByteBuffer input); }
|
AbstractNonStreamingHashFunction extends AbstractHashFunction { @Override public Hasher newHasher() { return newHasher(32); } @Override Hasher newHasher(); @Override Hasher newHasher(int expectedInputSize); @Override HashCode hashInt(int input); @Override HashCode hashLong(long input); @Override HashCode hashUnencodedChars(CharSequence input); @Override HashCode hashString(CharSequence input, Charset charset); @Override abstract HashCode hashBytes(byte[] input, int off, int len); @Override HashCode hashBytes(ByteBuffer input); }
|
@Test void testFloat() { Sink sink = new Sink(4); sink.putFloat(Float.intBitsToFloat(0x04030201)); HashCode unused = sink.hash(); sink.assertInvariants(4); sink.assertBytes(new byte[]{1, 2, 3, 4}); }
|
@Override public final HashCode hash() { munch(); buffer.flip(); if (buffer.remaining() > 0) { processRemaining(buffer); buffer.position(buffer.limit()); } return makeHash(); }
|
AbstractStreamingHasher extends AbstractHasher { @Override public final HashCode hash() { munch(); buffer.flip(); if (buffer.remaining() > 0) { processRemaining(buffer); buffer.position(buffer.limit()); } return makeHash(); } }
|
AbstractStreamingHasher extends AbstractHasher { @Override public final HashCode hash() { munch(); buffer.flip(); if (buffer.remaining() > 0) { processRemaining(buffer); buffer.position(buffer.limit()); } return makeHash(); } protected AbstractStreamingHasher(int chunkSize); protected AbstractStreamingHasher(int chunkSize, int bufferSize); }
|
AbstractStreamingHasher extends AbstractHasher { @Override public final HashCode hash() { munch(); buffer.flip(); if (buffer.remaining() > 0) { processRemaining(buffer); buffer.position(buffer.limit()); } return makeHash(); } protected AbstractStreamingHasher(int chunkSize); protected AbstractStreamingHasher(int chunkSize, int bufferSize); @Override final Hasher putBytes(byte[] bytes, int off, int len); @Override final Hasher putBytes(ByteBuffer readBuffer); @Override final Hasher putByte(byte b); @Override final Hasher putShort(short s); @Override final Hasher putChar(char c); @Override final Hasher putInt(int i); @Override final Hasher putLong(long l); @Override final HashCode hash(); }
|
AbstractStreamingHasher extends AbstractHasher { @Override public final HashCode hash() { munch(); buffer.flip(); if (buffer.remaining() > 0) { processRemaining(buffer); buffer.position(buffer.limit()); } return makeHash(); } protected AbstractStreamingHasher(int chunkSize); protected AbstractStreamingHasher(int chunkSize, int bufferSize); @Override final Hasher putBytes(byte[] bytes, int off, int len); @Override final Hasher putBytes(ByteBuffer readBuffer); @Override final Hasher putByte(byte b); @Override final Hasher putShort(short s); @Override final Hasher putChar(char c); @Override final Hasher putInt(int i); @Override final Hasher putLong(long l); @Override final HashCode hash(); }
|
@Test void testDouble() { Sink sink = new Sink(8); sink.putDouble(Double.longBitsToDouble(0x0807060504030201L)); HashCode unused = sink.hash(); sink.assertInvariants(8); sink.assertBytes(new byte[]{1, 2, 3, 4, 5, 6, 7, 8}); }
|
@Override public final HashCode hash() { munch(); buffer.flip(); if (buffer.remaining() > 0) { processRemaining(buffer); buffer.position(buffer.limit()); } return makeHash(); }
|
AbstractStreamingHasher extends AbstractHasher { @Override public final HashCode hash() { munch(); buffer.flip(); if (buffer.remaining() > 0) { processRemaining(buffer); buffer.position(buffer.limit()); } return makeHash(); } }
|
AbstractStreamingHasher extends AbstractHasher { @Override public final HashCode hash() { munch(); buffer.flip(); if (buffer.remaining() > 0) { processRemaining(buffer); buffer.position(buffer.limit()); } return makeHash(); } protected AbstractStreamingHasher(int chunkSize); protected AbstractStreamingHasher(int chunkSize, int bufferSize); }
|
AbstractStreamingHasher extends AbstractHasher { @Override public final HashCode hash() { munch(); buffer.flip(); if (buffer.remaining() > 0) { processRemaining(buffer); buffer.position(buffer.limit()); } return makeHash(); } protected AbstractStreamingHasher(int chunkSize); protected AbstractStreamingHasher(int chunkSize, int bufferSize); @Override final Hasher putBytes(byte[] bytes, int off, int len); @Override final Hasher putBytes(ByteBuffer readBuffer); @Override final Hasher putByte(byte b); @Override final Hasher putShort(short s); @Override final Hasher putChar(char c); @Override final Hasher putInt(int i); @Override final Hasher putLong(long l); @Override final HashCode hash(); }
|
AbstractStreamingHasher extends AbstractHasher { @Override public final HashCode hash() { munch(); buffer.flip(); if (buffer.remaining() > 0) { processRemaining(buffer); buffer.position(buffer.limit()); } return makeHash(); } protected AbstractStreamingHasher(int chunkSize); protected AbstractStreamingHasher(int chunkSize, int bufferSize); @Override final Hasher putBytes(byte[] bytes, int off, int len); @Override final Hasher putBytes(ByteBuffer readBuffer); @Override final Hasher putByte(byte b); @Override final Hasher putShort(short s); @Override final Hasher putChar(char c); @Override final Hasher putInt(int i); @Override final Hasher putLong(long l); @Override final HashCode hash(); }
|
@Test void testCorrectExceptions() { Sink sink = new Sink(4); assertThrows(IndexOutOfBoundsException.class, () -> sink.putBytes(new byte[8], -1, 4)); assertThrows(IndexOutOfBoundsException.class, () -> sink.putBytes(new byte[8], 0, 16)); assertThrows(IndexOutOfBoundsException.class, () -> sink.putBytes(new byte[8], 0, -1)); }
|
@Override public final Hasher putBytes(byte[] bytes, int off, int len) { return putBytesInternal(ByteBuffer.wrap(bytes, off, len).order(ByteOrder.LITTLE_ENDIAN)); }
|
AbstractStreamingHasher extends AbstractHasher { @Override public final Hasher putBytes(byte[] bytes, int off, int len) { return putBytesInternal(ByteBuffer.wrap(bytes, off, len).order(ByteOrder.LITTLE_ENDIAN)); } }
|
AbstractStreamingHasher extends AbstractHasher { @Override public final Hasher putBytes(byte[] bytes, int off, int len) { return putBytesInternal(ByteBuffer.wrap(bytes, off, len).order(ByteOrder.LITTLE_ENDIAN)); } protected AbstractStreamingHasher(int chunkSize); protected AbstractStreamingHasher(int chunkSize, int bufferSize); }
|
AbstractStreamingHasher extends AbstractHasher { @Override public final Hasher putBytes(byte[] bytes, int off, int len) { return putBytesInternal(ByteBuffer.wrap(bytes, off, len).order(ByteOrder.LITTLE_ENDIAN)); } protected AbstractStreamingHasher(int chunkSize); protected AbstractStreamingHasher(int chunkSize, int bufferSize); @Override final Hasher putBytes(byte[] bytes, int off, int len); @Override final Hasher putBytes(ByteBuffer readBuffer); @Override final Hasher putByte(byte b); @Override final Hasher putShort(short s); @Override final Hasher putChar(char c); @Override final Hasher putInt(int i); @Override final Hasher putLong(long l); @Override final HashCode hash(); }
|
AbstractStreamingHasher extends AbstractHasher { @Override public final Hasher putBytes(byte[] bytes, int off, int len) { return putBytesInternal(ByteBuffer.wrap(bytes, off, len).order(ByteOrder.LITTLE_ENDIAN)); } protected AbstractStreamingHasher(int chunkSize); protected AbstractStreamingHasher(int chunkSize, int bufferSize); @Override final Hasher putBytes(byte[] bytes, int off, int len); @Override final Hasher putBytes(ByteBuffer readBuffer); @Override final Hasher putByte(byte b); @Override final Hasher putShort(short s); @Override final Hasher putChar(char c); @Override final Hasher putInt(int i); @Override final Hasher putLong(long l); @Override final HashCode hash(); }
|
@Test void testToString() { assertEquals("Hashing.sha256()", Hashing.sha256().toString()); assertEquals("Hashing.sha512()", Hashing.sha512().toString()); }
|
@Override public String toString() { return toString; }
|
MessageDigestHashFunction extends AbstractHashFunction implements Serializable { @Override public String toString() { return toString; } }
|
MessageDigestHashFunction extends AbstractHashFunction implements Serializable { @Override public String toString() { return toString; } MessageDigestHashFunction(String algorithmName, String toString); MessageDigestHashFunction(String algorithmName, int bytes, String toString); }
|
MessageDigestHashFunction extends AbstractHashFunction implements Serializable { @Override public String toString() { return toString; } MessageDigestHashFunction(String algorithmName, String toString); MessageDigestHashFunction(String algorithmName, int bytes, String toString); @Override int bits(); @Override String toString(); @Override Hasher newHasher(); }
|
MessageDigestHashFunction extends AbstractHashFunction implements Serializable { @Override public String toString() { return toString; } MessageDigestHashFunction(String algorithmName, String toString); MessageDigestHashFunction(String algorithmName, int bytes, String toString); @Override int bits(); @Override String toString(); @Override Hasher newHasher(); }
|
@Test void configure() { Injector injector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(ServiceInstanceSpec.class).toInstance(ServiceInstanceSpec.newInstance("test", 1, ServiceArtifactId.newJavaId("a/b", "1"))); } }, new FakeServiceModule()); Service instance = injector.getInstance(Service.class); assertNotNull(instance); assertThat(instance, instanceOf(FakeService.class)); }
|
@Override protected void configure() { bind(Service.class).to(FakeService.class) .in(Singleton.class); }
|
FakeServiceModule extends AbstractServiceModule { @Override protected void configure() { bind(Service.class).to(FakeService.class) .in(Singleton.class); } }
|
FakeServiceModule extends AbstractServiceModule { @Override protected void configure() { bind(Service.class).to(FakeService.class) .in(Singleton.class); } }
|
FakeServiceModule extends AbstractServiceModule { @Override protected void configure() { bind(Service.class).to(FakeService.class) .in(Singleton.class); } }
|
FakeServiceModule extends AbstractServiceModule { @Override protected void configure() { bind(Service.class).to(FakeService.class) .in(Singleton.class); } }
|
@Test void testShort() { TestHasher hasher = new TestHasher(); hasher.putShort((short) 0x0201); hasher.assertBytes(new byte[]{1, 2}); }
|
@Override public Hasher putShort(short s) { scratch.putShort(s); return update(Shorts.BYTES); }
|
AbstractByteHasher extends AbstractHasher { @Override public Hasher putShort(short s) { scratch.putShort(s); return update(Shorts.BYTES); } }
|
AbstractByteHasher extends AbstractHasher { @Override public Hasher putShort(short s) { scratch.putShort(s); return update(Shorts.BYTES); } }
|
AbstractByteHasher extends AbstractHasher { @Override public Hasher putShort(short s) { scratch.putShort(s); return update(Shorts.BYTES); } @Override Hasher putByte(byte b); @Override Hasher putBytes(byte[] bytes); @Override Hasher putBytes(byte[] bytes, int off, int len); @Override Hasher putBytes(ByteBuffer bytes); @Override Hasher putShort(short s); @Override Hasher putInt(int i); @Override Hasher putLong(long l); @Override Hasher putChar(char c); }
|
AbstractByteHasher extends AbstractHasher { @Override public Hasher putShort(short s) { scratch.putShort(s); return update(Shorts.BYTES); } @Override Hasher putByte(byte b); @Override Hasher putBytes(byte[] bytes); @Override Hasher putBytes(byte[] bytes, int off, int len); @Override Hasher putBytes(ByteBuffer bytes); @Override Hasher putShort(short s); @Override Hasher putInt(int i); @Override Hasher putLong(long l); @Override Hasher putChar(char c); }
|
@Test void testInt() { TestHasher hasher = new TestHasher(); hasher.putInt(0x04030201); hasher.assertBytes(new byte[]{1, 2, 3, 4}); }
|
@Override public Hasher putInt(int i) { scratch.putInt(i); return update(Ints.BYTES); }
|
AbstractByteHasher extends AbstractHasher { @Override public Hasher putInt(int i) { scratch.putInt(i); return update(Ints.BYTES); } }
|
AbstractByteHasher extends AbstractHasher { @Override public Hasher putInt(int i) { scratch.putInt(i); return update(Ints.BYTES); } }
|
AbstractByteHasher extends AbstractHasher { @Override public Hasher putInt(int i) { scratch.putInt(i); return update(Ints.BYTES); } @Override Hasher putByte(byte b); @Override Hasher putBytes(byte[] bytes); @Override Hasher putBytes(byte[] bytes, int off, int len); @Override Hasher putBytes(ByteBuffer bytes); @Override Hasher putShort(short s); @Override Hasher putInt(int i); @Override Hasher putLong(long l); @Override Hasher putChar(char c); }
|
AbstractByteHasher extends AbstractHasher { @Override public Hasher putInt(int i) { scratch.putInt(i); return update(Ints.BYTES); } @Override Hasher putByte(byte b); @Override Hasher putBytes(byte[] bytes); @Override Hasher putBytes(byte[] bytes, int off, int len); @Override Hasher putBytes(ByteBuffer bytes); @Override Hasher putShort(short s); @Override Hasher putInt(int i); @Override Hasher putLong(long l); @Override Hasher putChar(char c); }
|
@Test void testLong() { TestHasher hasher = new TestHasher(); hasher.putLong(0x0807060504030201L); hasher.assertBytes(new byte[]{1, 2, 3, 4, 5, 6, 7, 8}); }
|
@Override public Hasher putLong(long l) { scratch.putLong(l); return update(Longs.BYTES); }
|
AbstractByteHasher extends AbstractHasher { @Override public Hasher putLong(long l) { scratch.putLong(l); return update(Longs.BYTES); } }
|
AbstractByteHasher extends AbstractHasher { @Override public Hasher putLong(long l) { scratch.putLong(l); return update(Longs.BYTES); } }
|
AbstractByteHasher extends AbstractHasher { @Override public Hasher putLong(long l) { scratch.putLong(l); return update(Longs.BYTES); } @Override Hasher putByte(byte b); @Override Hasher putBytes(byte[] bytes); @Override Hasher putBytes(byte[] bytes, int off, int len); @Override Hasher putBytes(ByteBuffer bytes); @Override Hasher putShort(short s); @Override Hasher putInt(int i); @Override Hasher putLong(long l); @Override Hasher putChar(char c); }
|
AbstractByteHasher extends AbstractHasher { @Override public Hasher putLong(long l) { scratch.putLong(l); return update(Longs.BYTES); } @Override Hasher putByte(byte b); @Override Hasher putBytes(byte[] bytes); @Override Hasher putBytes(byte[] bytes, int off, int len); @Override Hasher putBytes(ByteBuffer bytes); @Override Hasher putShort(short s); @Override Hasher putInt(int i); @Override Hasher putLong(long l); @Override Hasher putChar(char c); }
|
@Test void testChar() { TestHasher hasher = new TestHasher(); hasher.putChar((char) 0x0201); hasher.assertBytes(new byte[]{1, 2}); }
|
@Override public Hasher putChar(char c) { scratch.putChar(c); return update(Chars.BYTES); }
|
AbstractByteHasher extends AbstractHasher { @Override public Hasher putChar(char c) { scratch.putChar(c); return update(Chars.BYTES); } }
|
AbstractByteHasher extends AbstractHasher { @Override public Hasher putChar(char c) { scratch.putChar(c); return update(Chars.BYTES); } }
|
AbstractByteHasher extends AbstractHasher { @Override public Hasher putChar(char c) { scratch.putChar(c); return update(Chars.BYTES); } @Override Hasher putByte(byte b); @Override Hasher putBytes(byte[] bytes); @Override Hasher putBytes(byte[] bytes, int off, int len); @Override Hasher putBytes(ByteBuffer bytes); @Override Hasher putShort(short s); @Override Hasher putInt(int i); @Override Hasher putLong(long l); @Override Hasher putChar(char c); }
|
AbstractByteHasher extends AbstractHasher { @Override public Hasher putChar(char c) { scratch.putChar(c); return update(Chars.BYTES); } @Override Hasher putByte(byte b); @Override Hasher putBytes(byte[] bytes); @Override Hasher putBytes(byte[] bytes, int off, int len); @Override Hasher putBytes(ByteBuffer bytes); @Override Hasher putShort(short s); @Override Hasher putInt(int i); @Override Hasher putLong(long l); @Override Hasher putChar(char c); }
|
@Test void testString() { Random random = new Random(); for (int i = 0; i < 100; i++) { byte[] bytes = new byte[64]; random.nextBytes(bytes); String s = new String(bytes, UTF_16LE); assertEquals( new TestHasher().putUnencodedChars(s).hash(), new TestHasher().putBytes(s.getBytes(UTF_16LE)).hash()); assertEquals( new TestHasher().putUnencodedChars(s).hash(), new TestHasher().putString(s, UTF_16LE).hash()); } }
|
@Override public Hasher putBytes(byte[] bytes) { checkNotNull(bytes); update(bytes); return this; }
|
AbstractByteHasher extends AbstractHasher { @Override public Hasher putBytes(byte[] bytes) { checkNotNull(bytes); update(bytes); return this; } }
|
AbstractByteHasher extends AbstractHasher { @Override public Hasher putBytes(byte[] bytes) { checkNotNull(bytes); update(bytes); return this; } }
|
AbstractByteHasher extends AbstractHasher { @Override public Hasher putBytes(byte[] bytes) { checkNotNull(bytes); update(bytes); return this; } @Override Hasher putByte(byte b); @Override Hasher putBytes(byte[] bytes); @Override Hasher putBytes(byte[] bytes, int off, int len); @Override Hasher putBytes(ByteBuffer bytes); @Override Hasher putShort(short s); @Override Hasher putInt(int i); @Override Hasher putLong(long l); @Override Hasher putChar(char c); }
|
AbstractByteHasher extends AbstractHasher { @Override public Hasher putBytes(byte[] bytes) { checkNotNull(bytes); update(bytes); return this; } @Override Hasher putByte(byte b); @Override Hasher putBytes(byte[] bytes); @Override Hasher putBytes(byte[] bytes, int off, int len); @Override Hasher putBytes(ByteBuffer bytes); @Override Hasher putShort(short s); @Override Hasher putInt(int i); @Override Hasher putLong(long l); @Override Hasher putChar(char c); }
|
@Test void testCorrectExceptions() { TestHasher hasher = new TestHasher(); assertThrows(IndexOutOfBoundsException.class, () -> hasher.putBytes(new byte[8], -1, 4)); assertThrows(IndexOutOfBoundsException.class, () -> hasher.putBytes(new byte[8], 0, 16)); assertThrows(IndexOutOfBoundsException.class, () -> hasher.putBytes(new byte[8], 0, -1)); }
|
@Override public Hasher putBytes(byte[] bytes) { checkNotNull(bytes); update(bytes); return this; }
|
AbstractByteHasher extends AbstractHasher { @Override public Hasher putBytes(byte[] bytes) { checkNotNull(bytes); update(bytes); return this; } }
|
AbstractByteHasher extends AbstractHasher { @Override public Hasher putBytes(byte[] bytes) { checkNotNull(bytes); update(bytes); return this; } }
|
AbstractByteHasher extends AbstractHasher { @Override public Hasher putBytes(byte[] bytes) { checkNotNull(bytes); update(bytes); return this; } @Override Hasher putByte(byte b); @Override Hasher putBytes(byte[] bytes); @Override Hasher putBytes(byte[] bytes, int off, int len); @Override Hasher putBytes(ByteBuffer bytes); @Override Hasher putShort(short s); @Override Hasher putInt(int i); @Override Hasher putLong(long l); @Override Hasher putChar(char c); }
|
AbstractByteHasher extends AbstractHasher { @Override public Hasher putBytes(byte[] bytes) { checkNotNull(bytes); update(bytes); return this; } @Override Hasher putByte(byte b); @Override Hasher putBytes(byte[] bytes); @Override Hasher putBytes(byte[] bytes, int off, int len); @Override Hasher putBytes(ByteBuffer bytes); @Override Hasher putShort(short s); @Override Hasher putInt(int i); @Override Hasher putLong(long l); @Override Hasher putChar(char c); }
|
@Test void testGetHashOfEmptyArray() { HashFunction f = Hashing.defaultHashFunction(); assertThat(f.hashBytes(bytes()), equalTo(ZERO_HASH_CODE)); }
|
public static HashFunction defaultHashFunction() { return sha256(); }
|
Hashing { public static HashFunction defaultHashFunction() { return sha256(); } }
|
Hashing { public static HashFunction defaultHashFunction() { return sha256(); } private Hashing(); }
|
Hashing { public static HashFunction defaultHashFunction() { return sha256(); } private Hashing(); static HashFunction sha256(); static HashFunction defaultHashFunction(); static HashFunction sha384(); static HashFunction sha512(); }
|
Hashing { public static HashFunction defaultHashFunction() { return sha256(); } private Hashing(); static HashFunction sha256(); static HashFunction defaultHashFunction(); static HashFunction sha384(); static HashFunction sha512(); static final int DEFAULT_HASH_SIZE_BYTES; static final int DEFAULT_HASH_SIZE_BITS; }
|
@Test void testGetHashOfEmptyByteBuffer() { HashFunction f = Hashing.defaultHashFunction(); assertThat(f.hashBytes(ByteBuffer.allocate(0)), equalTo(ZERO_HASH_CODE)); }
|
public static HashFunction defaultHashFunction() { return sha256(); }
|
Hashing { public static HashFunction defaultHashFunction() { return sha256(); } }
|
Hashing { public static HashFunction defaultHashFunction() { return sha256(); } private Hashing(); }
|
Hashing { public static HashFunction defaultHashFunction() { return sha256(); } private Hashing(); static HashFunction sha256(); static HashFunction defaultHashFunction(); static HashFunction sha384(); static HashFunction sha512(); }
|
Hashing { public static HashFunction defaultHashFunction() { return sha256(); } private Hashing(); static HashFunction sha256(); static HashFunction defaultHashFunction(); static HashFunction sha384(); static HashFunction sha512(); static final int DEFAULT_HASH_SIZE_BYTES; static final int DEFAULT_HASH_SIZE_BITS; }
|
@Test void testSha256() { HashTestUtils.checkAvalanche(Hashing.sha256(), 100, 0.4); HashTestUtils.checkNo2BitCharacteristics(Hashing.sha256()); HashTestUtils.checkNoFunnels(Hashing.sha256()); HashTestUtils.assertInvariants(Hashing.sha256()); assertEquals("Hashing.sha256()", Hashing.sha256().toString()); }
|
public static HashFunction sha256() { return Sha256Holder.SHA_256; }
|
Hashing { public static HashFunction sha256() { return Sha256Holder.SHA_256; } }
|
Hashing { public static HashFunction sha256() { return Sha256Holder.SHA_256; } private Hashing(); }
|
Hashing { public static HashFunction sha256() { return Sha256Holder.SHA_256; } private Hashing(); static HashFunction sha256(); static HashFunction defaultHashFunction(); static HashFunction sha384(); static HashFunction sha512(); }
|
Hashing { public static HashFunction sha256() { return Sha256Holder.SHA_256; } private Hashing(); static HashFunction sha256(); static HashFunction defaultHashFunction(); static HashFunction sha384(); static HashFunction sha512(); static final int DEFAULT_HASH_SIZE_BYTES; static final int DEFAULT_HASH_SIZE_BITS; }
|
@Test void testSha384() { HashTestUtils.checkAvalanche(Hashing.sha384(), 100, 0.4); HashTestUtils.checkNo2BitCharacteristics(Hashing.sha384()); HashTestUtils.checkNoFunnels(Hashing.sha384()); HashTestUtils.assertInvariants(Hashing.sha384()); assertEquals("Hashing.sha384()", Hashing.sha384().toString()); }
|
public static HashFunction sha384() { return Sha384Holder.SHA_384; }
|
Hashing { public static HashFunction sha384() { return Sha384Holder.SHA_384; } }
|
Hashing { public static HashFunction sha384() { return Sha384Holder.SHA_384; } private Hashing(); }
|
Hashing { public static HashFunction sha384() { return Sha384Holder.SHA_384; } private Hashing(); static HashFunction sha256(); static HashFunction defaultHashFunction(); static HashFunction sha384(); static HashFunction sha512(); }
|
Hashing { public static HashFunction sha384() { return Sha384Holder.SHA_384; } private Hashing(); static HashFunction sha256(); static HashFunction defaultHashFunction(); static HashFunction sha384(); static HashFunction sha512(); static final int DEFAULT_HASH_SIZE_BYTES; static final int DEFAULT_HASH_SIZE_BITS; }
|
@Test void submitIncrementCounter(VertxTestContext context) { long seed = 1L; String counterName = "counter1"; MultiMap params = multiMap("seed", Long.toString(seed), "counterName", counterName); when(qaService.submitIncrementCounter(eq(seed), eq(counterName))) .thenReturn(EXPECTED_TX_HASH); post(SUBMIT_INCREMENT_COUNTER_TX_PATH) .sendForm(params, checkCreatedTransaction(context, EXPECTED_TX_HASH)); }
|
private void submitIncrementCounter(RoutingContext rc) { MultiMap parameters = rc.request().params(); long seed = getRequiredParameter(parameters, "seed", Long::parseLong); String counterName = getRequiredParameter(parameters, COUNTER_NAME_PARAM, identity()); HashCode txHash = service.submitIncrementCounter(seed, counterName); replyTxSubmitted(rc, txHash); }
|
ApiController { private void submitIncrementCounter(RoutingContext rc) { MultiMap parameters = rc.request().params(); long seed = getRequiredParameter(parameters, "seed", Long::parseLong); String counterName = getRequiredParameter(parameters, COUNTER_NAME_PARAM, identity()); HashCode txHash = service.submitIncrementCounter(seed, counterName); replyTxSubmitted(rc, txHash); } }
|
ApiController { private void submitIncrementCounter(RoutingContext rc) { MultiMap parameters = rc.request().params(); long seed = getRequiredParameter(parameters, "seed", Long::parseLong); String counterName = getRequiredParameter(parameters, COUNTER_NAME_PARAM, identity()); HashCode txHash = service.submitIncrementCounter(seed, counterName); replyTxSubmitted(rc, txHash); } ApiController(QaService service); }
|
ApiController { private void submitIncrementCounter(RoutingContext rc) { MultiMap parameters = rc.request().params(); long seed = getRequiredParameter(parameters, "seed", Long::parseLong); String counterName = getRequiredParameter(parameters, COUNTER_NAME_PARAM, identity()); HashCode txHash = service.submitIncrementCounter(seed, counterName); replyTxSubmitted(rc, txHash); } ApiController(QaService service); }
|
ApiController { private void submitIncrementCounter(RoutingContext rc) { MultiMap parameters = rc.request().params(); long seed = getRequiredParameter(parameters, "seed", Long::parseLong); String counterName = getRequiredParameter(parameters, COUNTER_NAME_PARAM, identity()); HashCode txHash = service.submitIncrementCounter(seed, counterName); replyTxSubmitted(rc, txHash); } ApiController(QaService service); }
|
@Test void testSha512() { HashTestUtils.checkAvalanche(Hashing.sha512(), 100, 0.4); HashTestUtils.checkNo2BitCharacteristics(Hashing.sha512()); HashTestUtils.checkNoFunnels(Hashing.sha512()); HashTestUtils.assertInvariants(Hashing.sha512()); assertEquals("Hashing.sha512()", Hashing.sha512().toString()); }
|
public static HashFunction sha512() { return Sha512Holder.SHA_512; }
|
Hashing { public static HashFunction sha512() { return Sha512Holder.SHA_512; } }
|
Hashing { public static HashFunction sha512() { return Sha512Holder.SHA_512; } private Hashing(); }
|
Hashing { public static HashFunction sha512() { return Sha512Holder.SHA_512; } private Hashing(); static HashFunction sha256(); static HashFunction defaultHashFunction(); static HashFunction sha384(); static HashFunction sha512(); }
|
Hashing { public static HashFunction sha512() { return Sha512Holder.SHA_512; } private Hashing(); static HashFunction sha256(); static HashFunction defaultHashFunction(); static HashFunction sha384(); static HashFunction sha512(); static final int DEFAULT_HASH_SIZE_BYTES; static final int DEFAULT_HASH_SIZE_BITS; }
|
@Test void testFromInt() { for (ExpectedHashCode expected : expectedHashCodes) { if (expected.bytes.length == 4) { HashCode fromInt = HashCode.fromInt(expected.asInt); assertExpectedHashCode(expected, fromInt); } } }
|
public static HashCode fromInt(int hash) { return new IntHashCode(hash); }
|
HashCode { public static HashCode fromInt(int hash) { return new IntHashCode(hash); } }
|
HashCode { public static HashCode fromInt(int hash) { return new IntHashCode(hash); } HashCode(); }
|
HashCode { public static HashCode fromInt(int hash) { return new IntHashCode(hash); } HashCode(); abstract int bits(); abstract int asInt(); abstract long asLong(); abstract long padToLong(); abstract byte[] asBytes(); @CanIgnoreReturnValue int writeBytesTo(byte[] dest, int offset, int maxLength); static HashCode fromInt(int hash); static HashCode fromLong(long hash); static HashCode fromBytes(byte[] bytes); static HashCode fromString(String string); @Override final boolean equals(@Nullable Object object); @Override final int hashCode(); @Override final String toString(); }
|
HashCode { public static HashCode fromInt(int hash) { return new IntHashCode(hash); } HashCode(); abstract int bits(); abstract int asInt(); abstract long asLong(); abstract long padToLong(); abstract byte[] asBytes(); @CanIgnoreReturnValue int writeBytesTo(byte[] dest, int offset, int maxLength); static HashCode fromInt(int hash); static HashCode fromLong(long hash); static HashCode fromBytes(byte[] bytes); static HashCode fromString(String string); @Override final boolean equals(@Nullable Object object); @Override final int hashCode(); @Override final String toString(); }
|
@Test void testFromLong() { for (ExpectedHashCode expected : expectedHashCodes) { if (expected.bytes.length == 8) { HashCode fromLong = HashCode.fromLong(expected.asLong); assertExpectedHashCode(expected, fromLong); } } }
|
public static HashCode fromLong(long hash) { return new LongHashCode(hash); }
|
HashCode { public static HashCode fromLong(long hash) { return new LongHashCode(hash); } }
|
HashCode { public static HashCode fromLong(long hash) { return new LongHashCode(hash); } HashCode(); }
|
HashCode { public static HashCode fromLong(long hash) { return new LongHashCode(hash); } HashCode(); abstract int bits(); abstract int asInt(); abstract long asLong(); abstract long padToLong(); abstract byte[] asBytes(); @CanIgnoreReturnValue int writeBytesTo(byte[] dest, int offset, int maxLength); static HashCode fromInt(int hash); static HashCode fromLong(long hash); static HashCode fromBytes(byte[] bytes); static HashCode fromString(String string); @Override final boolean equals(@Nullable Object object); @Override final int hashCode(); @Override final String toString(); }
|
HashCode { public static HashCode fromLong(long hash) { return new LongHashCode(hash); } HashCode(); abstract int bits(); abstract int asInt(); abstract long asLong(); abstract long padToLong(); abstract byte[] asBytes(); @CanIgnoreReturnValue int writeBytesTo(byte[] dest, int offset, int maxLength); static HashCode fromInt(int hash); static HashCode fromLong(long hash); static HashCode fromBytes(byte[] bytes); static HashCode fromString(String string); @Override final boolean equals(@Nullable Object object); @Override final int hashCode(); @Override final String toString(); }
|
@Test void testFromBytes() { for (ExpectedHashCode expected : expectedHashCodes) { HashCode fromBytes = HashCode.fromBytes(expected.bytes); assertExpectedHashCode(expected, fromBytes); } }
|
public static HashCode fromBytes(byte[] bytes) { checkArgument(bytes.length >= 1, "A HashCode must contain at least 1 byte."); return fromBytesNoCopy(bytes.clone()); }
|
HashCode { public static HashCode fromBytes(byte[] bytes) { checkArgument(bytes.length >= 1, "A HashCode must contain at least 1 byte."); return fromBytesNoCopy(bytes.clone()); } }
|
HashCode { public static HashCode fromBytes(byte[] bytes) { checkArgument(bytes.length >= 1, "A HashCode must contain at least 1 byte."); return fromBytesNoCopy(bytes.clone()); } HashCode(); }
|
HashCode { public static HashCode fromBytes(byte[] bytes) { checkArgument(bytes.length >= 1, "A HashCode must contain at least 1 byte."); return fromBytesNoCopy(bytes.clone()); } HashCode(); abstract int bits(); abstract int asInt(); abstract long asLong(); abstract long padToLong(); abstract byte[] asBytes(); @CanIgnoreReturnValue int writeBytesTo(byte[] dest, int offset, int maxLength); static HashCode fromInt(int hash); static HashCode fromLong(long hash); static HashCode fromBytes(byte[] bytes); static HashCode fromString(String string); @Override final boolean equals(@Nullable Object object); @Override final int hashCode(); @Override final String toString(); }
|
HashCode { public static HashCode fromBytes(byte[] bytes) { checkArgument(bytes.length >= 1, "A HashCode must contain at least 1 byte."); return fromBytesNoCopy(bytes.clone()); } HashCode(); abstract int bits(); abstract int asInt(); abstract long asLong(); abstract long padToLong(); abstract byte[] asBytes(); @CanIgnoreReturnValue int writeBytesTo(byte[] dest, int offset, int maxLength); static HashCode fromInt(int hash); static HashCode fromLong(long hash); static HashCode fromBytes(byte[] bytes); static HashCode fromString(String string); @Override final boolean equals(@Nullable Object object); @Override final int hashCode(); @Override final String toString(); }
|
@Test void testPadToLong() { assertEquals(0x1111111111111111L, HashCode.fromLong(0x1111111111111111L).padToLong()); assertEquals(0x9999999999999999L, HashCode.fromLong(0x9999999999999999L).padToLong()); assertEquals(0x0000000011111111L, HashCode.fromInt(0x11111111).padToLong()); assertEquals(0x0000000099999999L, HashCode.fromInt(0x99999999).padToLong()); }
|
public abstract long padToLong();
|
HashCode { public abstract long padToLong(); }
|
HashCode { public abstract long padToLong(); HashCode(); }
|
HashCode { public abstract long padToLong(); HashCode(); abstract int bits(); abstract int asInt(); abstract long asLong(); abstract long padToLong(); abstract byte[] asBytes(); @CanIgnoreReturnValue int writeBytesTo(byte[] dest, int offset, int maxLength); static HashCode fromInt(int hash); static HashCode fromLong(long hash); static HashCode fromBytes(byte[] bytes); static HashCode fromString(String string); @Override final boolean equals(@Nullable Object object); @Override final int hashCode(); @Override final String toString(); }
|
HashCode { public abstract long padToLong(); HashCode(); abstract int bits(); abstract int asInt(); abstract long asLong(); abstract long padToLong(); abstract byte[] asBytes(); @CanIgnoreReturnValue int writeBytesTo(byte[] dest, int offset, int maxLength); static HashCode fromInt(int hash); static HashCode fromLong(long hash); static HashCode fromBytes(byte[] bytes); static HashCode fromString(String string); @Override final boolean equals(@Nullable Object object); @Override final int hashCode(); @Override final String toString(); }
|
@Test void testToString() { byte[] data = new byte[]{127, -128, 5, -1, 14}; assertEquals("7f8005ff0e", HashCode.fromBytes(data).toString()); assertEquals("7f8005ff0e", base16().lowerCase().encode(data)); }
|
@Override public final String toString() { byte[] bytes = getBytesInternal(); StringBuilder sb = new StringBuilder(2 * bytes.length); for (byte b : bytes) { sb.append(hexDigits[(b >> 4) & 0xf]).append(hexDigits[b & 0xf]); } return sb.toString(); }
|
HashCode { @Override public final String toString() { byte[] bytes = getBytesInternal(); StringBuilder sb = new StringBuilder(2 * bytes.length); for (byte b : bytes) { sb.append(hexDigits[(b >> 4) & 0xf]).append(hexDigits[b & 0xf]); } return sb.toString(); } }
|
HashCode { @Override public final String toString() { byte[] bytes = getBytesInternal(); StringBuilder sb = new StringBuilder(2 * bytes.length); for (byte b : bytes) { sb.append(hexDigits[(b >> 4) & 0xf]).append(hexDigits[b & 0xf]); } return sb.toString(); } HashCode(); }
|
HashCode { @Override public final String toString() { byte[] bytes = getBytesInternal(); StringBuilder sb = new StringBuilder(2 * bytes.length); for (byte b : bytes) { sb.append(hexDigits[(b >> 4) & 0xf]).append(hexDigits[b & 0xf]); } return sb.toString(); } HashCode(); abstract int bits(); abstract int asInt(); abstract long asLong(); abstract long padToLong(); abstract byte[] asBytes(); @CanIgnoreReturnValue int writeBytesTo(byte[] dest, int offset, int maxLength); static HashCode fromInt(int hash); static HashCode fromLong(long hash); static HashCode fromBytes(byte[] bytes); static HashCode fromString(String string); @Override final boolean equals(@Nullable Object object); @Override final int hashCode(); @Override final String toString(); }
|
HashCode { @Override public final String toString() { byte[] bytes = getBytesInternal(); StringBuilder sb = new StringBuilder(2 * bytes.length); for (byte b : bytes) { sb.append(hexDigits[(b >> 4) & 0xf]).append(hexDigits[b & 0xf]); } return sb.toString(); } HashCode(); abstract int bits(); abstract int asInt(); abstract long asLong(); abstract long padToLong(); abstract byte[] asBytes(); @CanIgnoreReturnValue int writeBytesTo(byte[] dest, int offset, int maxLength); static HashCode fromInt(int hash); static HashCode fromLong(long hash); static HashCode fromBytes(byte[] bytes); static HashCode fromString(String string); @Override final boolean equals(@Nullable Object object); @Override final int hashCode(); @Override final String toString(); }
|
@Test void testFromStringFailsWithInvalidHexChar() { assertThrows(IllegalArgumentException.class, () -> HashCode.fromString("7f8005ff0z")); }
|
public static HashCode fromString(String string) { checkArgument( string.length() >= 2, "input string (%s) must have at least 2 characters", string); checkArgument( string.length() % 2 == 0, "input string (%s) must have an even number of characters", string); byte[] bytes = new byte[string.length() / 2]; for (int i = 0; i < string.length(); i += 2) { int ch1 = decode(string.charAt(i)) << 4; int ch2 = decode(string.charAt(i + 1)); bytes[i / 2] = (byte) (ch1 + ch2); } return fromBytesNoCopy(bytes); }
|
HashCode { public static HashCode fromString(String string) { checkArgument( string.length() >= 2, "input string (%s) must have at least 2 characters", string); checkArgument( string.length() % 2 == 0, "input string (%s) must have an even number of characters", string); byte[] bytes = new byte[string.length() / 2]; for (int i = 0; i < string.length(); i += 2) { int ch1 = decode(string.charAt(i)) << 4; int ch2 = decode(string.charAt(i + 1)); bytes[i / 2] = (byte) (ch1 + ch2); } return fromBytesNoCopy(bytes); } }
|
HashCode { public static HashCode fromString(String string) { checkArgument( string.length() >= 2, "input string (%s) must have at least 2 characters", string); checkArgument( string.length() % 2 == 0, "input string (%s) must have an even number of characters", string); byte[] bytes = new byte[string.length() / 2]; for (int i = 0; i < string.length(); i += 2) { int ch1 = decode(string.charAt(i)) << 4; int ch2 = decode(string.charAt(i + 1)); bytes[i / 2] = (byte) (ch1 + ch2); } return fromBytesNoCopy(bytes); } HashCode(); }
|
HashCode { public static HashCode fromString(String string) { checkArgument( string.length() >= 2, "input string (%s) must have at least 2 characters", string); checkArgument( string.length() % 2 == 0, "input string (%s) must have an even number of characters", string); byte[] bytes = new byte[string.length() / 2]; for (int i = 0; i < string.length(); i += 2) { int ch1 = decode(string.charAt(i)) << 4; int ch2 = decode(string.charAt(i + 1)); bytes[i / 2] = (byte) (ch1 + ch2); } return fromBytesNoCopy(bytes); } HashCode(); abstract int bits(); abstract int asInt(); abstract long asLong(); abstract long padToLong(); abstract byte[] asBytes(); @CanIgnoreReturnValue int writeBytesTo(byte[] dest, int offset, int maxLength); static HashCode fromInt(int hash); static HashCode fromLong(long hash); static HashCode fromBytes(byte[] bytes); static HashCode fromString(String string); @Override final boolean equals(@Nullable Object object); @Override final int hashCode(); @Override final String toString(); }
|
HashCode { public static HashCode fromString(String string) { checkArgument( string.length() >= 2, "input string (%s) must have at least 2 characters", string); checkArgument( string.length() % 2 == 0, "input string (%s) must have an even number of characters", string); byte[] bytes = new byte[string.length() / 2]; for (int i = 0; i < string.length(); i += 2) { int ch1 = decode(string.charAt(i)) << 4; int ch2 = decode(string.charAt(i + 1)); bytes[i / 2] = (byte) (ch1 + ch2); } return fromBytesNoCopy(bytes); } HashCode(); abstract int bits(); abstract int asInt(); abstract long asLong(); abstract long padToLong(); abstract byte[] asBytes(); @CanIgnoreReturnValue int writeBytesTo(byte[] dest, int offset, int maxLength); static HashCode fromInt(int hash); static HashCode fromLong(long hash); static HashCode fromBytes(byte[] bytes); static HashCode fromString(String string); @Override final boolean equals(@Nullable Object object); @Override final int hashCode(); @Override final String toString(); }
|
@Test void testFromStringFailsWithShortInputs() { assertThrows(IllegalArgumentException.class, () -> HashCode.fromString("")); assertThrows(IllegalArgumentException.class, () -> HashCode.fromString("7")); HashCode unused = HashCode.fromString("7f"); }
|
public static HashCode fromString(String string) { checkArgument( string.length() >= 2, "input string (%s) must have at least 2 characters", string); checkArgument( string.length() % 2 == 0, "input string (%s) must have an even number of characters", string); byte[] bytes = new byte[string.length() / 2]; for (int i = 0; i < string.length(); i += 2) { int ch1 = decode(string.charAt(i)) << 4; int ch2 = decode(string.charAt(i + 1)); bytes[i / 2] = (byte) (ch1 + ch2); } return fromBytesNoCopy(bytes); }
|
HashCode { public static HashCode fromString(String string) { checkArgument( string.length() >= 2, "input string (%s) must have at least 2 characters", string); checkArgument( string.length() % 2 == 0, "input string (%s) must have an even number of characters", string); byte[] bytes = new byte[string.length() / 2]; for (int i = 0; i < string.length(); i += 2) { int ch1 = decode(string.charAt(i)) << 4; int ch2 = decode(string.charAt(i + 1)); bytes[i / 2] = (byte) (ch1 + ch2); } return fromBytesNoCopy(bytes); } }
|
HashCode { public static HashCode fromString(String string) { checkArgument( string.length() >= 2, "input string (%s) must have at least 2 characters", string); checkArgument( string.length() % 2 == 0, "input string (%s) must have an even number of characters", string); byte[] bytes = new byte[string.length() / 2]; for (int i = 0; i < string.length(); i += 2) { int ch1 = decode(string.charAt(i)) << 4; int ch2 = decode(string.charAt(i + 1)); bytes[i / 2] = (byte) (ch1 + ch2); } return fromBytesNoCopy(bytes); } HashCode(); }
|
HashCode { public static HashCode fromString(String string) { checkArgument( string.length() >= 2, "input string (%s) must have at least 2 characters", string); checkArgument( string.length() % 2 == 0, "input string (%s) must have an even number of characters", string); byte[] bytes = new byte[string.length() / 2]; for (int i = 0; i < string.length(); i += 2) { int ch1 = decode(string.charAt(i)) << 4; int ch2 = decode(string.charAt(i + 1)); bytes[i / 2] = (byte) (ch1 + ch2); } return fromBytesNoCopy(bytes); } HashCode(); abstract int bits(); abstract int asInt(); abstract long asLong(); abstract long padToLong(); abstract byte[] asBytes(); @CanIgnoreReturnValue int writeBytesTo(byte[] dest, int offset, int maxLength); static HashCode fromInt(int hash); static HashCode fromLong(long hash); static HashCode fromBytes(byte[] bytes); static HashCode fromString(String string); @Override final boolean equals(@Nullable Object object); @Override final int hashCode(); @Override final String toString(); }
|
HashCode { public static HashCode fromString(String string) { checkArgument( string.length() >= 2, "input string (%s) must have at least 2 characters", string); checkArgument( string.length() % 2 == 0, "input string (%s) must have an even number of characters", string); byte[] bytes = new byte[string.length() / 2]; for (int i = 0; i < string.length(); i += 2) { int ch1 = decode(string.charAt(i)) << 4; int ch2 = decode(string.charAt(i + 1)); bytes[i / 2] = (byte) (ch1 + ch2); } return fromBytesNoCopy(bytes); } HashCode(); abstract int bits(); abstract int asInt(); abstract long asLong(); abstract long padToLong(); abstract byte[] asBytes(); @CanIgnoreReturnValue int writeBytesTo(byte[] dest, int offset, int maxLength); static HashCode fromInt(int hash); static HashCode fromLong(long hash); static HashCode fromBytes(byte[] bytes); static HashCode fromString(String string); @Override final boolean equals(@Nullable Object object); @Override final int hashCode(); @Override final String toString(); }
|
@Test void testFromStringFailsWithOddLengthInput() { assertThrows(IllegalArgumentException.class, () -> HashCode.fromString("7f8")); }
|
public static HashCode fromString(String string) { checkArgument( string.length() >= 2, "input string (%s) must have at least 2 characters", string); checkArgument( string.length() % 2 == 0, "input string (%s) must have an even number of characters", string); byte[] bytes = new byte[string.length() / 2]; for (int i = 0; i < string.length(); i += 2) { int ch1 = decode(string.charAt(i)) << 4; int ch2 = decode(string.charAt(i + 1)); bytes[i / 2] = (byte) (ch1 + ch2); } return fromBytesNoCopy(bytes); }
|
HashCode { public static HashCode fromString(String string) { checkArgument( string.length() >= 2, "input string (%s) must have at least 2 characters", string); checkArgument( string.length() % 2 == 0, "input string (%s) must have an even number of characters", string); byte[] bytes = new byte[string.length() / 2]; for (int i = 0; i < string.length(); i += 2) { int ch1 = decode(string.charAt(i)) << 4; int ch2 = decode(string.charAt(i + 1)); bytes[i / 2] = (byte) (ch1 + ch2); } return fromBytesNoCopy(bytes); } }
|
HashCode { public static HashCode fromString(String string) { checkArgument( string.length() >= 2, "input string (%s) must have at least 2 characters", string); checkArgument( string.length() % 2 == 0, "input string (%s) must have an even number of characters", string); byte[] bytes = new byte[string.length() / 2]; for (int i = 0; i < string.length(); i += 2) { int ch1 = decode(string.charAt(i)) << 4; int ch2 = decode(string.charAt(i + 1)); bytes[i / 2] = (byte) (ch1 + ch2); } return fromBytesNoCopy(bytes); } HashCode(); }
|
HashCode { public static HashCode fromString(String string) { checkArgument( string.length() >= 2, "input string (%s) must have at least 2 characters", string); checkArgument( string.length() % 2 == 0, "input string (%s) must have an even number of characters", string); byte[] bytes = new byte[string.length() / 2]; for (int i = 0; i < string.length(); i += 2) { int ch1 = decode(string.charAt(i)) << 4; int ch2 = decode(string.charAt(i + 1)); bytes[i / 2] = (byte) (ch1 + ch2); } return fromBytesNoCopy(bytes); } HashCode(); abstract int bits(); abstract int asInt(); abstract long asLong(); abstract long padToLong(); abstract byte[] asBytes(); @CanIgnoreReturnValue int writeBytesTo(byte[] dest, int offset, int maxLength); static HashCode fromInt(int hash); static HashCode fromLong(long hash); static HashCode fromBytes(byte[] bytes); static HashCode fromString(String string); @Override final boolean equals(@Nullable Object object); @Override final int hashCode(); @Override final String toString(); }
|
HashCode { public static HashCode fromString(String string) { checkArgument( string.length() >= 2, "input string (%s) must have at least 2 characters", string); checkArgument( string.length() % 2 == 0, "input string (%s) must have an even number of characters", string); byte[] bytes = new byte[string.length() / 2]; for (int i = 0; i < string.length(); i += 2) { int ch1 = decode(string.charAt(i)) << 4; int ch2 = decode(string.charAt(i + 1)); bytes[i / 2] = (byte) (ch1 + ch2); } return fromBytesNoCopy(bytes); } HashCode(); abstract int bits(); abstract int asInt(); abstract long asLong(); abstract long padToLong(); abstract byte[] asBytes(); @CanIgnoreReturnValue int writeBytesTo(byte[] dest, int offset, int maxLength); static HashCode fromInt(int hash); static HashCode fromLong(long hash); static HashCode fromBytes(byte[] bytes); static HashCode fromString(String string); @Override final boolean equals(@Nullable Object object); @Override final int hashCode(); @Override final String toString(); }
|
@Test void testWriteBytesTo() { byte[] dest = new byte[4]; HASH_ABCD.writeBytesTo(dest, 0, 4); assertArrayEquals(new byte[]{(byte) 0xaa, (byte) 0xbb, (byte) 0xcc, (byte) 0xdd}, dest); }
|
@CanIgnoreReturnValue public int writeBytesTo(byte[] dest, int offset, int maxLength) { maxLength = Ints.min(maxLength, bits() / 8); Preconditions.checkPositionIndexes(offset, offset + maxLength, dest.length); writeBytesToImpl(dest, offset, maxLength); return maxLength; }
|
HashCode { @CanIgnoreReturnValue public int writeBytesTo(byte[] dest, int offset, int maxLength) { maxLength = Ints.min(maxLength, bits() / 8); Preconditions.checkPositionIndexes(offset, offset + maxLength, dest.length); writeBytesToImpl(dest, offset, maxLength); return maxLength; } }
|
HashCode { @CanIgnoreReturnValue public int writeBytesTo(byte[] dest, int offset, int maxLength) { maxLength = Ints.min(maxLength, bits() / 8); Preconditions.checkPositionIndexes(offset, offset + maxLength, dest.length); writeBytesToImpl(dest, offset, maxLength); return maxLength; } HashCode(); }
|
HashCode { @CanIgnoreReturnValue public int writeBytesTo(byte[] dest, int offset, int maxLength) { maxLength = Ints.min(maxLength, bits() / 8); Preconditions.checkPositionIndexes(offset, offset + maxLength, dest.length); writeBytesToImpl(dest, offset, maxLength); return maxLength; } HashCode(); abstract int bits(); abstract int asInt(); abstract long asLong(); abstract long padToLong(); abstract byte[] asBytes(); @CanIgnoreReturnValue int writeBytesTo(byte[] dest, int offset, int maxLength); static HashCode fromInt(int hash); static HashCode fromLong(long hash); static HashCode fromBytes(byte[] bytes); static HashCode fromString(String string); @Override final boolean equals(@Nullable Object object); @Override final int hashCode(); @Override final String toString(); }
|
HashCode { @CanIgnoreReturnValue public int writeBytesTo(byte[] dest, int offset, int maxLength) { maxLength = Ints.min(maxLength, bits() / 8); Preconditions.checkPositionIndexes(offset, offset + maxLength, dest.length); writeBytesToImpl(dest, offset, maxLength); return maxLength; } HashCode(); abstract int bits(); abstract int asInt(); abstract long asLong(); abstract long padToLong(); abstract byte[] asBytes(); @CanIgnoreReturnValue int writeBytesTo(byte[] dest, int offset, int maxLength); static HashCode fromInt(int hash); static HashCode fromLong(long hash); static HashCode fromBytes(byte[] bytes); static HashCode fromString(String string); @Override final boolean equals(@Nullable Object object); @Override final int hashCode(); @Override final String toString(); }
|
@Test void submitUnknown(VertxTestContext context) { when(qaService.submitUnknownTx()) .thenReturn(EXPECTED_TX_HASH); post(SUBMIT_UNKNOWN_TX_PATH) .send(checkCreatedTransaction(context, EXPECTED_TX_HASH)); }
|
private void submitUnknownTx(RoutingContext rc) { HashCode txHash = service.submitUnknownTx(); replyTxSubmitted(rc, txHash); }
|
ApiController { private void submitUnknownTx(RoutingContext rc) { HashCode txHash = service.submitUnknownTx(); replyTxSubmitted(rc, txHash); } }
|
ApiController { private void submitUnknownTx(RoutingContext rc) { HashCode txHash = service.submitUnknownTx(); replyTxSubmitted(rc, txHash); } ApiController(QaService service); }
|
ApiController { private void submitUnknownTx(RoutingContext rc) { HashCode txHash = service.submitUnknownTx(); replyTxSubmitted(rc, txHash); } ApiController(QaService service); }
|
ApiController { private void submitUnknownTx(RoutingContext rc) { HashCode txHash = service.submitUnknownTx(); replyTxSubmitted(rc, txHash); } ApiController(QaService service); }
|
@Test public void validateLogin_Success() throws Exception { when(mModel.mLoginValidator.isValid(any())).thenReturn(true); assertThat(mModel.isValidateLogin(), is(true)); assertThat(Strings.isNullOrEmpty(mModel.mLoginError.get()), is(true)); }
|
public boolean isValidateLogin() { boolean valid = true; if (mLoginValidator != null && !mLoginValidator.isValid(mLogin.get())) { mLoginError.set(mViewAccess.getLoginErrorMessage()); valid = false; } else { mLoginError.set(null); } return valid; }
|
ForgotPasswordViewModel { public boolean isValidateLogin() { boolean valid = true; if (mLoginValidator != null && !mLoginValidator.isValid(mLogin.get())) { mLoginError.set(mViewAccess.getLoginErrorMessage()); valid = false; } else { mLoginError.set(null); } return valid; } }
|
ForgotPasswordViewModel { public boolean isValidateLogin() { boolean valid = true; if (mLoginValidator != null && !mLoginValidator.isValid(mLogin.get())) { mLoginError.set(mViewAccess.getLoginErrorMessage()); valid = false; } else { mLoginError.set(null); } return valid; } @Inject ForgotPasswordViewModel(); }
|
ForgotPasswordViewModel { public boolean isValidateLogin() { boolean valid = true; if (mLoginValidator != null && !mLoginValidator.isValid(mLogin.get())) { mLoginError.set(mViewAccess.getLoginErrorMessage()); valid = false; } else { mLoginError.set(null); } return valid; } @Inject ForgotPasswordViewModel(); boolean isValidateLogin(); }
|
ForgotPasswordViewModel { public boolean isValidateLogin() { boolean valid = true; if (mLoginValidator != null && !mLoginValidator.isValid(mLogin.get())) { mLoginError.set(mViewAccess.getLoginErrorMessage()); valid = false; } else { mLoginError.set(null); } return valid; } @Inject ForgotPasswordViewModel(); boolean isValidateLogin(); final ObservableString mLogin; final ObservableString mLoginError; }
|
@Test public void validatePassword_Error() throws Exception { when(mModel.mPasswordValidator.isValid(any())).thenReturn(false); when(mModel.mViewAccess.getPasswordErrorMessage()).thenReturn("error"); assertThat(mModel.isPasswordValid(), is(false)); assertThat(Strings.isNullOrEmpty(mModel.mPasswordError.get()), is(false)); }
|
protected boolean isPasswordValid() { boolean valid = true; if (mPasswordValidator != null && !mPasswordValidator.isValid(mPassword.get())) { mPasswordError.set(mViewAccess.getPasswordErrorMessage()); valid = false; } else { mPasswordError.set(null); } return valid; }
|
RegisterViewModel extends BaseViewModel { protected boolean isPasswordValid() { boolean valid = true; if (mPasswordValidator != null && !mPasswordValidator.isValid(mPassword.get())) { mPasswordError.set(mViewAccess.getPasswordErrorMessage()); valid = false; } else { mPasswordError.set(null); } return valid; } }
|
RegisterViewModel extends BaseViewModel { protected boolean isPasswordValid() { boolean valid = true; if (mPasswordValidator != null && !mPasswordValidator.isValid(mPassword.get())) { mPasswordError.set(mViewAccess.getPasswordErrorMessage()); valid = false; } else { mPasswordError.set(null); } return valid; } @Inject RegisterViewModel(); }
|
RegisterViewModel extends BaseViewModel { protected boolean isPasswordValid() { boolean valid = true; if (mPasswordValidator != null && !mPasswordValidator.isValid(mPassword.get())) { mPasswordError.set(mViewAccess.getPasswordErrorMessage()); valid = false; } else { mPasswordError.set(null); } return valid; } @Inject RegisterViewModel(); boolean isInputDataValid(); }
|
RegisterViewModel extends BaseViewModel { protected boolean isPasswordValid() { boolean valid = true; if (mPasswordValidator != null && !mPasswordValidator.isValid(mPassword.get())) { mPasswordError.set(mViewAccess.getPasswordErrorMessage()); valid = false; } else { mPasswordError.set(null); } return valid; } @Inject RegisterViewModel(); boolean isInputDataValid(); final ObservableString mLogin; final ObservableString mFirstName; final ObservableString mLastName; final ObservableString mPassword; final ObservableString mConfirmPassword; final ObservableString mLoginError; final ObservableString mFirstNameError; final ObservableString mLastNameError; final ObservableString mPasswordError; final ObservableString mConfirmPasswordError; }
|
@Test public void validatePasswordConfirm_Success() throws Exception { String password = "pass123"; mModel.mPassword.set(password); mModel.mConfirmPassword.set(password); assertThat(mModel.isConfirmPasswordValid(), is(true)); assertThat(Strings.isNullOrEmpty(mModel.mConfirmPasswordError.get()), is(true)); }
|
protected boolean isConfirmPasswordValid() { boolean valid = true; if (!Strings.isNullOrEmpty(mPassword.get()) && !Strings.isNullOrEmpty(mConfirmPassword.get()) && mPassword.get().equals(mConfirmPassword.get())) { mConfirmPasswordError.set(null); } else { mConfirmPasswordError.set(mViewAccess.getConfirmPasswordErrorMessage()); valid = false; } return valid; }
|
RegisterViewModel extends BaseViewModel { protected boolean isConfirmPasswordValid() { boolean valid = true; if (!Strings.isNullOrEmpty(mPassword.get()) && !Strings.isNullOrEmpty(mConfirmPassword.get()) && mPassword.get().equals(mConfirmPassword.get())) { mConfirmPasswordError.set(null); } else { mConfirmPasswordError.set(mViewAccess.getConfirmPasswordErrorMessage()); valid = false; } return valid; } }
|
RegisterViewModel extends BaseViewModel { protected boolean isConfirmPasswordValid() { boolean valid = true; if (!Strings.isNullOrEmpty(mPassword.get()) && !Strings.isNullOrEmpty(mConfirmPassword.get()) && mPassword.get().equals(mConfirmPassword.get())) { mConfirmPasswordError.set(null); } else { mConfirmPasswordError.set(mViewAccess.getConfirmPasswordErrorMessage()); valid = false; } return valid; } @Inject RegisterViewModel(); }
|
RegisterViewModel extends BaseViewModel { protected boolean isConfirmPasswordValid() { boolean valid = true; if (!Strings.isNullOrEmpty(mPassword.get()) && !Strings.isNullOrEmpty(mConfirmPassword.get()) && mPassword.get().equals(mConfirmPassword.get())) { mConfirmPasswordError.set(null); } else { mConfirmPasswordError.set(mViewAccess.getConfirmPasswordErrorMessage()); valid = false; } return valid; } @Inject RegisterViewModel(); boolean isInputDataValid(); }
|
RegisterViewModel extends BaseViewModel { protected boolean isConfirmPasswordValid() { boolean valid = true; if (!Strings.isNullOrEmpty(mPassword.get()) && !Strings.isNullOrEmpty(mConfirmPassword.get()) && mPassword.get().equals(mConfirmPassword.get())) { mConfirmPasswordError.set(null); } else { mConfirmPasswordError.set(mViewAccess.getConfirmPasswordErrorMessage()); valid = false; } return valid; } @Inject RegisterViewModel(); boolean isInputDataValid(); final ObservableString mLogin; final ObservableString mFirstName; final ObservableString mLastName; final ObservableString mPassword; final ObservableString mConfirmPassword; final ObservableString mLoginError; final ObservableString mFirstNameError; final ObservableString mLastNameError; final ObservableString mPasswordError; final ObservableString mConfirmPasswordError; }
|
@Test public void validatePasswordConfirm_Error() throws Exception { when(mModel.mViewAccess.getConfirmPasswordErrorMessage()).thenReturn("error"); String password = "pass123"; mModel.mPassword.set(password); mModel.mConfirmPassword.set(""); assertThat(mModel.isConfirmPasswordValid(), is(false)); assertThat(Strings.isNullOrEmpty(mModel.mConfirmPasswordError.get()), is(false)); }
|
protected boolean isConfirmPasswordValid() { boolean valid = true; if (!Strings.isNullOrEmpty(mPassword.get()) && !Strings.isNullOrEmpty(mConfirmPassword.get()) && mPassword.get().equals(mConfirmPassword.get())) { mConfirmPasswordError.set(null); } else { mConfirmPasswordError.set(mViewAccess.getConfirmPasswordErrorMessage()); valid = false; } return valid; }
|
RegisterViewModel extends BaseViewModel { protected boolean isConfirmPasswordValid() { boolean valid = true; if (!Strings.isNullOrEmpty(mPassword.get()) && !Strings.isNullOrEmpty(mConfirmPassword.get()) && mPassword.get().equals(mConfirmPassword.get())) { mConfirmPasswordError.set(null); } else { mConfirmPasswordError.set(mViewAccess.getConfirmPasswordErrorMessage()); valid = false; } return valid; } }
|
RegisterViewModel extends BaseViewModel { protected boolean isConfirmPasswordValid() { boolean valid = true; if (!Strings.isNullOrEmpty(mPassword.get()) && !Strings.isNullOrEmpty(mConfirmPassword.get()) && mPassword.get().equals(mConfirmPassword.get())) { mConfirmPasswordError.set(null); } else { mConfirmPasswordError.set(mViewAccess.getConfirmPasswordErrorMessage()); valid = false; } return valid; } @Inject RegisterViewModel(); }
|
RegisterViewModel extends BaseViewModel { protected boolean isConfirmPasswordValid() { boolean valid = true; if (!Strings.isNullOrEmpty(mPassword.get()) && !Strings.isNullOrEmpty(mConfirmPassword.get()) && mPassword.get().equals(mConfirmPassword.get())) { mConfirmPasswordError.set(null); } else { mConfirmPasswordError.set(mViewAccess.getConfirmPasswordErrorMessage()); valid = false; } return valid; } @Inject RegisterViewModel(); boolean isInputDataValid(); }
|
RegisterViewModel extends BaseViewModel { protected boolean isConfirmPasswordValid() { boolean valid = true; if (!Strings.isNullOrEmpty(mPassword.get()) && !Strings.isNullOrEmpty(mConfirmPassword.get()) && mPassword.get().equals(mConfirmPassword.get())) { mConfirmPasswordError.set(null); } else { mConfirmPasswordError.set(mViewAccess.getConfirmPasswordErrorMessage()); valid = false; } return valid; } @Inject RegisterViewModel(); boolean isInputDataValid(); final ObservableString mLogin; final ObservableString mFirstName; final ObservableString mLastName; final ObservableString mPassword; final ObservableString mConfirmPassword; final ObservableString mLoginError; final ObservableString mFirstNameError; final ObservableString mLastNameError; final ObservableString mPasswordError; final ObservableString mConfirmPasswordError; }
|
@Test public void setLoginValidator_Correct() throws Exception { Validator validator = new EmailValidator(); mModel.setLoginValidator(validator); assertThat(mModel.mLoginValidator, is(validator)); }
|
protected void setLoginValidator(@Nullable Validator validator) { mLoginValidator = validator; }
|
RegisterViewModel extends BaseViewModel { protected void setLoginValidator(@Nullable Validator validator) { mLoginValidator = validator; } }
|
RegisterViewModel extends BaseViewModel { protected void setLoginValidator(@Nullable Validator validator) { mLoginValidator = validator; } @Inject RegisterViewModel(); }
|
RegisterViewModel extends BaseViewModel { protected void setLoginValidator(@Nullable Validator validator) { mLoginValidator = validator; } @Inject RegisterViewModel(); boolean isInputDataValid(); }
|
RegisterViewModel extends BaseViewModel { protected void setLoginValidator(@Nullable Validator validator) { mLoginValidator = validator; } @Inject RegisterViewModel(); boolean isInputDataValid(); final ObservableString mLogin; final ObservableString mFirstName; final ObservableString mLastName; final ObservableString mPassword; final ObservableString mConfirmPassword; final ObservableString mLoginError; final ObservableString mFirstNameError; final ObservableString mLastNameError; final ObservableString mPasswordError; final ObservableString mConfirmPasswordError; }
|
@Test public void setFirstNameValidator_Correct() throws Exception { Validator validator = new EmailValidator(); mModel.setFirstNameValidator(validator); assertThat(mModel.mFirstNameValidator, is(validator)); }
|
protected void setFirstNameValidator(@Nullable Validator validator) { mFirstNameValidator = validator; }
|
RegisterViewModel extends BaseViewModel { protected void setFirstNameValidator(@Nullable Validator validator) { mFirstNameValidator = validator; } }
|
RegisterViewModel extends BaseViewModel { protected void setFirstNameValidator(@Nullable Validator validator) { mFirstNameValidator = validator; } @Inject RegisterViewModel(); }
|
RegisterViewModel extends BaseViewModel { protected void setFirstNameValidator(@Nullable Validator validator) { mFirstNameValidator = validator; } @Inject RegisterViewModel(); boolean isInputDataValid(); }
|
RegisterViewModel extends BaseViewModel { protected void setFirstNameValidator(@Nullable Validator validator) { mFirstNameValidator = validator; } @Inject RegisterViewModel(); boolean isInputDataValid(); final ObservableString mLogin; final ObservableString mFirstName; final ObservableString mLastName; final ObservableString mPassword; final ObservableString mConfirmPassword; final ObservableString mLoginError; final ObservableString mFirstNameError; final ObservableString mLastNameError; final ObservableString mPasswordError; final ObservableString mConfirmPasswordError; }
|
@Test public void setLastNameValidator_Correct() throws Exception { Validator validator = new EmailValidator(); mModel.setLastNameValidator(validator); assertThat(mModel.mLastNameValidator, is(validator)); }
|
protected void setLastNameValidator(@Nullable Validator validator) { mLastNameValidator = validator; }
|
RegisterViewModel extends BaseViewModel { protected void setLastNameValidator(@Nullable Validator validator) { mLastNameValidator = validator; } }
|
RegisterViewModel extends BaseViewModel { protected void setLastNameValidator(@Nullable Validator validator) { mLastNameValidator = validator; } @Inject RegisterViewModel(); }
|
RegisterViewModel extends BaseViewModel { protected void setLastNameValidator(@Nullable Validator validator) { mLastNameValidator = validator; } @Inject RegisterViewModel(); boolean isInputDataValid(); }
|
RegisterViewModel extends BaseViewModel { protected void setLastNameValidator(@Nullable Validator validator) { mLastNameValidator = validator; } @Inject RegisterViewModel(); boolean isInputDataValid(); final ObservableString mLogin; final ObservableString mFirstName; final ObservableString mLastName; final ObservableString mPassword; final ObservableString mConfirmPassword; final ObservableString mLoginError; final ObservableString mFirstNameError; final ObservableString mLastNameError; final ObservableString mPasswordError; final ObservableString mConfirmPasswordError; }
|
@Test public void setPasswordValidator_Correct() throws Exception { Validator validator = new EmailValidator(); mModel.setPasswordValidator(validator); assertThat(mModel.mPasswordValidator, is(validator)); }
|
protected void setPasswordValidator(@Nullable Validator validator) { mPasswordValidator = validator; }
|
RegisterViewModel extends BaseViewModel { protected void setPasswordValidator(@Nullable Validator validator) { mPasswordValidator = validator; } }
|
RegisterViewModel extends BaseViewModel { protected void setPasswordValidator(@Nullable Validator validator) { mPasswordValidator = validator; } @Inject RegisterViewModel(); }
|
RegisterViewModel extends BaseViewModel { protected void setPasswordValidator(@Nullable Validator validator) { mPasswordValidator = validator; } @Inject RegisterViewModel(); boolean isInputDataValid(); }
|
RegisterViewModel extends BaseViewModel { protected void setPasswordValidator(@Nullable Validator validator) { mPasswordValidator = validator; } @Inject RegisterViewModel(); boolean isInputDataValid(); final ObservableString mLogin; final ObservableString mFirstName; final ObservableString mLastName; final ObservableString mPassword; final ObservableString mConfirmPassword; final ObservableString mLoginError; final ObservableString mFirstNameError; final ObservableString mLastNameError; final ObservableString mPasswordError; final ObservableString mConfirmPasswordError; }
|
@Test public void isFormValid_Correct() throws Exception { String password = "pass123"; when(mModel.mLoginValidator.isValid(any())).thenReturn(true); when(mModel.mFirstNameValidator.isValid(any())).thenReturn(true); when(mModel.mLastNameValidator.isValid(any())).thenReturn(true); when(mModel.mPasswordValidator.isValid(any())).thenReturn(true); mModel.mPassword.set(password); mModel.mConfirmPassword.set(password); assertThat(mModel.isInputDataValid(), is(true)); }
|
public boolean isInputDataValid() { return isLoginValid() && isFirstNameValid() && isLastNameValid() && isPasswordValid() && isConfirmPasswordValid(); }
|
RegisterViewModel extends BaseViewModel { public boolean isInputDataValid() { return isLoginValid() && isFirstNameValid() && isLastNameValid() && isPasswordValid() && isConfirmPasswordValid(); } }
|
RegisterViewModel extends BaseViewModel { public boolean isInputDataValid() { return isLoginValid() && isFirstNameValid() && isLastNameValid() && isPasswordValid() && isConfirmPasswordValid(); } @Inject RegisterViewModel(); }
|
RegisterViewModel extends BaseViewModel { public boolean isInputDataValid() { return isLoginValid() && isFirstNameValid() && isLastNameValid() && isPasswordValid() && isConfirmPasswordValid(); } @Inject RegisterViewModel(); boolean isInputDataValid(); }
|
RegisterViewModel extends BaseViewModel { public boolean isInputDataValid() { return isLoginValid() && isFirstNameValid() && isLastNameValid() && isPasswordValid() && isConfirmPasswordValid(); } @Inject RegisterViewModel(); boolean isInputDataValid(); final ObservableString mLogin; final ObservableString mFirstName; final ObservableString mLastName; final ObservableString mPassword; final ObservableString mConfirmPassword; final ObservableString mLoginError; final ObservableString mFirstNameError; final ObservableString mLastNameError; final ObservableString mPasswordError; final ObservableString mConfirmPasswordError; }
|
@Test public void isFormValid_ErrorLogin() throws Exception { String password = "pass123"; when(mModel.mLoginValidator.isValid(any())).thenReturn(false); when(mModel.mFirstNameValidator.isValid(any())).thenReturn(true); when(mModel.mLastNameValidator.isValid(any())).thenReturn(true); when(mModel.mPasswordValidator.isValid(any())).thenReturn(true); mModel.mPassword.set(password); mModel.mConfirmPassword.set(password); assertThat(mModel.isInputDataValid(), is(false)); }
|
public boolean isInputDataValid() { return isLoginValid() && isFirstNameValid() && isLastNameValid() && isPasswordValid() && isConfirmPasswordValid(); }
|
RegisterViewModel extends BaseViewModel { public boolean isInputDataValid() { return isLoginValid() && isFirstNameValid() && isLastNameValid() && isPasswordValid() && isConfirmPasswordValid(); } }
|
RegisterViewModel extends BaseViewModel { public boolean isInputDataValid() { return isLoginValid() && isFirstNameValid() && isLastNameValid() && isPasswordValid() && isConfirmPasswordValid(); } @Inject RegisterViewModel(); }
|
RegisterViewModel extends BaseViewModel { public boolean isInputDataValid() { return isLoginValid() && isFirstNameValid() && isLastNameValid() && isPasswordValid() && isConfirmPasswordValid(); } @Inject RegisterViewModel(); boolean isInputDataValid(); }
|
RegisterViewModel extends BaseViewModel { public boolean isInputDataValid() { return isLoginValid() && isFirstNameValid() && isLastNameValid() && isPasswordValid() && isConfirmPasswordValid(); } @Inject RegisterViewModel(); boolean isInputDataValid(); final ObservableString mLogin; final ObservableString mFirstName; final ObservableString mLastName; final ObservableString mPassword; final ObservableString mConfirmPassword; final ObservableString mLoginError; final ObservableString mFirstNameError; final ObservableString mLastNameError; final ObservableString mPasswordError; final ObservableString mConfirmPasswordError; }
|
@Test public void isFormValid_ErrorFirstName() throws Exception { String password = "pass123"; when(mModel.mLoginValidator.isValid(any())).thenReturn(true); when(mModel.mLastNameValidator.isValid(any())).thenReturn(true); when(mModel.mFirstNameValidator.isValid(any())).thenReturn(false); when(mModel.mPasswordValidator.isValid(any())).thenReturn(true); mModel.mPassword.set(password); mModel.mConfirmPassword.set(password); assertThat(mModel.isInputDataValid(), is(false)); }
|
public boolean isInputDataValid() { return isLoginValid() && isFirstNameValid() && isLastNameValid() && isPasswordValid() && isConfirmPasswordValid(); }
|
RegisterViewModel extends BaseViewModel { public boolean isInputDataValid() { return isLoginValid() && isFirstNameValid() && isLastNameValid() && isPasswordValid() && isConfirmPasswordValid(); } }
|
RegisterViewModel extends BaseViewModel { public boolean isInputDataValid() { return isLoginValid() && isFirstNameValid() && isLastNameValid() && isPasswordValid() && isConfirmPasswordValid(); } @Inject RegisterViewModel(); }
|
RegisterViewModel extends BaseViewModel { public boolean isInputDataValid() { return isLoginValid() && isFirstNameValid() && isLastNameValid() && isPasswordValid() && isConfirmPasswordValid(); } @Inject RegisterViewModel(); boolean isInputDataValid(); }
|
RegisterViewModel extends BaseViewModel { public boolean isInputDataValid() { return isLoginValid() && isFirstNameValid() && isLastNameValid() && isPasswordValid() && isConfirmPasswordValid(); } @Inject RegisterViewModel(); boolean isInputDataValid(); final ObservableString mLogin; final ObservableString mFirstName; final ObservableString mLastName; final ObservableString mPassword; final ObservableString mConfirmPassword; final ObservableString mLoginError; final ObservableString mFirstNameError; final ObservableString mLastNameError; final ObservableString mPasswordError; final ObservableString mConfirmPasswordError; }
|
@Test public void validateLogin_Error() throws Exception { when(mModel.mLoginValidator.isValid(any())).thenReturn(false); when(mModel.mViewAccess.getLoginErrorMessage()).thenReturn("error"); assertThat(mModel.isValidateLogin(), is(false)); assertThat(Strings.isNullOrEmpty(mModel.mLoginError.get()), is(false)); }
|
public boolean isValidateLogin() { boolean valid = true; if (mLoginValidator != null && !mLoginValidator.isValid(mLogin.get())) { mLoginError.set(mViewAccess.getLoginErrorMessage()); valid = false; } else { mLoginError.set(null); } return valid; }
|
ForgotPasswordViewModel { public boolean isValidateLogin() { boolean valid = true; if (mLoginValidator != null && !mLoginValidator.isValid(mLogin.get())) { mLoginError.set(mViewAccess.getLoginErrorMessage()); valid = false; } else { mLoginError.set(null); } return valid; } }
|
ForgotPasswordViewModel { public boolean isValidateLogin() { boolean valid = true; if (mLoginValidator != null && !mLoginValidator.isValid(mLogin.get())) { mLoginError.set(mViewAccess.getLoginErrorMessage()); valid = false; } else { mLoginError.set(null); } return valid; } @Inject ForgotPasswordViewModel(); }
|
ForgotPasswordViewModel { public boolean isValidateLogin() { boolean valid = true; if (mLoginValidator != null && !mLoginValidator.isValid(mLogin.get())) { mLoginError.set(mViewAccess.getLoginErrorMessage()); valid = false; } else { mLoginError.set(null); } return valid; } @Inject ForgotPasswordViewModel(); boolean isValidateLogin(); }
|
ForgotPasswordViewModel { public boolean isValidateLogin() { boolean valid = true; if (mLoginValidator != null && !mLoginValidator.isValid(mLogin.get())) { mLoginError.set(mViewAccess.getLoginErrorMessage()); valid = false; } else { mLoginError.set(null); } return valid; } @Inject ForgotPasswordViewModel(); boolean isValidateLogin(); final ObservableString mLogin; final ObservableString mLoginError; }
|
@Test public void isFormValid_ErrorLastName() throws Exception { String password = "pass123"; when(mModel.mLoginValidator.isValid(any())).thenReturn(true); when(mModel.mFirstNameValidator.isValid(any())).thenReturn(true); when(mModel.mLastNameValidator.isValid(any())).thenReturn(false); when(mModel.mPasswordValidator.isValid(any())).thenReturn(true); mModel.mPassword.set(password); mModel.mConfirmPassword.set(password); assertThat(mModel.isInputDataValid(), is(false)); }
|
public boolean isInputDataValid() { return isLoginValid() && isFirstNameValid() && isLastNameValid() && isPasswordValid() && isConfirmPasswordValid(); }
|
RegisterViewModel extends BaseViewModel { public boolean isInputDataValid() { return isLoginValid() && isFirstNameValid() && isLastNameValid() && isPasswordValid() && isConfirmPasswordValid(); } }
|
RegisterViewModel extends BaseViewModel { public boolean isInputDataValid() { return isLoginValid() && isFirstNameValid() && isLastNameValid() && isPasswordValid() && isConfirmPasswordValid(); } @Inject RegisterViewModel(); }
|
RegisterViewModel extends BaseViewModel { public boolean isInputDataValid() { return isLoginValid() && isFirstNameValid() && isLastNameValid() && isPasswordValid() && isConfirmPasswordValid(); } @Inject RegisterViewModel(); boolean isInputDataValid(); }
|
RegisterViewModel extends BaseViewModel { public boolean isInputDataValid() { return isLoginValid() && isFirstNameValid() && isLastNameValid() && isPasswordValid() && isConfirmPasswordValid(); } @Inject RegisterViewModel(); boolean isInputDataValid(); final ObservableString mLogin; final ObservableString mFirstName; final ObservableString mLastName; final ObservableString mPassword; final ObservableString mConfirmPassword; final ObservableString mLoginError; final ObservableString mFirstNameError; final ObservableString mLastNameError; final ObservableString mPasswordError; final ObservableString mConfirmPasswordError; }
|
@Test public void isFormValid_ErrorPassword() throws Exception { String password = "pass123"; when(mModel.mLoginValidator.isValid(any())).thenReturn(true); when(mModel.mFirstNameValidator.isValid(any())).thenReturn(true); when(mModel.mLastNameValidator.isValid(any())).thenReturn(true); when(mModel.mPasswordValidator.isValid(any())).thenReturn(false); mModel.mPassword.set(password); mModel.mConfirmPassword.set(password); assertThat(mModel.isInputDataValid(), is(false)); }
|
public boolean isInputDataValid() { return isLoginValid() && isFirstNameValid() && isLastNameValid() && isPasswordValid() && isConfirmPasswordValid(); }
|
RegisterViewModel extends BaseViewModel { public boolean isInputDataValid() { return isLoginValid() && isFirstNameValid() && isLastNameValid() && isPasswordValid() && isConfirmPasswordValid(); } }
|
RegisterViewModel extends BaseViewModel { public boolean isInputDataValid() { return isLoginValid() && isFirstNameValid() && isLastNameValid() && isPasswordValid() && isConfirmPasswordValid(); } @Inject RegisterViewModel(); }
|
RegisterViewModel extends BaseViewModel { public boolean isInputDataValid() { return isLoginValid() && isFirstNameValid() && isLastNameValid() && isPasswordValid() && isConfirmPasswordValid(); } @Inject RegisterViewModel(); boolean isInputDataValid(); }
|
RegisterViewModel extends BaseViewModel { public boolean isInputDataValid() { return isLoginValid() && isFirstNameValid() && isLastNameValid() && isPasswordValid() && isConfirmPasswordValid(); } @Inject RegisterViewModel(); boolean isInputDataValid(); final ObservableString mLogin; final ObservableString mFirstName; final ObservableString mLastName; final ObservableString mPassword; final ObservableString mConfirmPassword; final ObservableString mLoginError; final ObservableString mFirstNameError; final ObservableString mLastNameError; final ObservableString mPasswordError; final ObservableString mConfirmPasswordError; }
|
@Test public void isFormValid_ErrorConfirmPassword() throws Exception { String password = "pass123"; when(mModel.mLoginValidator.isValid(any())).thenReturn(true); when(mModel.mFirstNameValidator.isValid(any())).thenReturn(true); when(mModel.mLastNameValidator.isValid(any())).thenReturn(true); when(mModel.mPasswordValidator.isValid(any())).thenReturn(true); mModel.mPassword.set(password); mModel.mConfirmPassword.set(password + password); assertThat(mModel.isInputDataValid(), is(false)); }
|
public boolean isInputDataValid() { return isLoginValid() && isFirstNameValid() && isLastNameValid() && isPasswordValid() && isConfirmPasswordValid(); }
|
RegisterViewModel extends BaseViewModel { public boolean isInputDataValid() { return isLoginValid() && isFirstNameValid() && isLastNameValid() && isPasswordValid() && isConfirmPasswordValid(); } }
|
RegisterViewModel extends BaseViewModel { public boolean isInputDataValid() { return isLoginValid() && isFirstNameValid() && isLastNameValid() && isPasswordValid() && isConfirmPasswordValid(); } @Inject RegisterViewModel(); }
|
RegisterViewModel extends BaseViewModel { public boolean isInputDataValid() { return isLoginValid() && isFirstNameValid() && isLastNameValid() && isPasswordValid() && isConfirmPasswordValid(); } @Inject RegisterViewModel(); boolean isInputDataValid(); }
|
RegisterViewModel extends BaseViewModel { public boolean isInputDataValid() { return isLoginValid() && isFirstNameValid() && isLastNameValid() && isPasswordValid() && isConfirmPasswordValid(); } @Inject RegisterViewModel(); boolean isInputDataValid(); final ObservableString mLogin; final ObservableString mFirstName; final ObservableString mLastName; final ObservableString mPassword; final ObservableString mConfirmPassword; final ObservableString mLoginError; final ObservableString mFirstNameError; final ObservableString mLastNameError; final ObservableString mPasswordError; final ObservableString mConfirmPasswordError; }
|
@Test public void validateLogin_Success() throws Exception { when(mModel.mLoginValidator.isValid(any())).thenReturn(true); assertThat(mModel.isValidateLogin(), is(true)); assertThat(Strings.isNullOrEmpty(mModel.mLoginError.get()), is(true)); }
|
protected boolean isValidateLogin() { boolean valid = true; if (mLoginValidator != null && !mLoginValidator.isValid(mLogin.get())) { mLoginError.set(mViewAccess.getLoginErrorMessage()); valid = false; } else { mLoginError.set(null); } return valid; }
|
LoginViewModel extends BaseViewModel { protected boolean isValidateLogin() { boolean valid = true; if (mLoginValidator != null && !mLoginValidator.isValid(mLogin.get())) { mLoginError.set(mViewAccess.getLoginErrorMessage()); valid = false; } else { mLoginError.set(null); } return valid; } }
|
LoginViewModel extends BaseViewModel { protected boolean isValidateLogin() { boolean valid = true; if (mLoginValidator != null && !mLoginValidator.isValid(mLogin.get())) { mLoginError.set(mViewAccess.getLoginErrorMessage()); valid = false; } else { mLoginError.set(null); } return valid; } @Inject LoginViewModel(); }
|
LoginViewModel extends BaseViewModel { protected boolean isValidateLogin() { boolean valid = true; if (mLoginValidator != null && !mLoginValidator.isValid(mLogin.get())) { mLoginError.set(mViewAccess.getLoginErrorMessage()); valid = false; } else { mLoginError.set(null); } return valid; } @Inject LoginViewModel(); boolean isInputDataValid(); }
|
LoginViewModel extends BaseViewModel { protected boolean isValidateLogin() { boolean valid = true; if (mLoginValidator != null && !mLoginValidator.isValid(mLogin.get())) { mLoginError.set(mViewAccess.getLoginErrorMessage()); valid = false; } else { mLoginError.set(null); } return valid; } @Inject LoginViewModel(); boolean isInputDataValid(); final ObservableString mLogin; final ObservableString mLoginError; final ObservableString mPassword; final ObservableString mPasswordError; }
|
@Test public void validateLogin_Error() throws Exception { when(mModel.mLoginValidator.isValid(any())).thenReturn(false); when(mModel.mViewAccess.getLoginErrorMessage()).thenReturn("error"); assertThat(mModel.isValidateLogin(), is(false)); assertThat(Strings.isNullOrEmpty(mModel.mLoginError.get()), is(false)); }
|
protected boolean isValidateLogin() { boolean valid = true; if (mLoginValidator != null && !mLoginValidator.isValid(mLogin.get())) { mLoginError.set(mViewAccess.getLoginErrorMessage()); valid = false; } else { mLoginError.set(null); } return valid; }
|
LoginViewModel extends BaseViewModel { protected boolean isValidateLogin() { boolean valid = true; if (mLoginValidator != null && !mLoginValidator.isValid(mLogin.get())) { mLoginError.set(mViewAccess.getLoginErrorMessage()); valid = false; } else { mLoginError.set(null); } return valid; } }
|
LoginViewModel extends BaseViewModel { protected boolean isValidateLogin() { boolean valid = true; if (mLoginValidator != null && !mLoginValidator.isValid(mLogin.get())) { mLoginError.set(mViewAccess.getLoginErrorMessage()); valid = false; } else { mLoginError.set(null); } return valid; } @Inject LoginViewModel(); }
|
LoginViewModel extends BaseViewModel { protected boolean isValidateLogin() { boolean valid = true; if (mLoginValidator != null && !mLoginValidator.isValid(mLogin.get())) { mLoginError.set(mViewAccess.getLoginErrorMessage()); valid = false; } else { mLoginError.set(null); } return valid; } @Inject LoginViewModel(); boolean isInputDataValid(); }
|
LoginViewModel extends BaseViewModel { protected boolean isValidateLogin() { boolean valid = true; if (mLoginValidator != null && !mLoginValidator.isValid(mLogin.get())) { mLoginError.set(mViewAccess.getLoginErrorMessage()); valid = false; } else { mLoginError.set(null); } return valid; } @Inject LoginViewModel(); boolean isInputDataValid(); final ObservableString mLogin; final ObservableString mLoginError; final ObservableString mPassword; final ObservableString mPasswordError; }
|
@Test public void validatePassword_Success() throws Exception { when(mModel.mPasswordValidator.isValid(any())).thenReturn(true); assertThat(mModel.isValidatePassword(), is(true)); assertThat(Strings.isNullOrEmpty(mModel.mPasswordError.get()), is(true)); }
|
protected boolean isValidatePassword() { boolean valid = true; if (mPasswordValidator != null && !mPasswordValidator.isValid(mPassword.get())) { mPasswordError.set(mViewAccess.getPasswordErrorMessage()); valid = false; } else { mPasswordError.set(null); } return valid; }
|
LoginViewModel extends BaseViewModel { protected boolean isValidatePassword() { boolean valid = true; if (mPasswordValidator != null && !mPasswordValidator.isValid(mPassword.get())) { mPasswordError.set(mViewAccess.getPasswordErrorMessage()); valid = false; } else { mPasswordError.set(null); } return valid; } }
|
LoginViewModel extends BaseViewModel { protected boolean isValidatePassword() { boolean valid = true; if (mPasswordValidator != null && !mPasswordValidator.isValid(mPassword.get())) { mPasswordError.set(mViewAccess.getPasswordErrorMessage()); valid = false; } else { mPasswordError.set(null); } return valid; } @Inject LoginViewModel(); }
|
LoginViewModel extends BaseViewModel { protected boolean isValidatePassword() { boolean valid = true; if (mPasswordValidator != null && !mPasswordValidator.isValid(mPassword.get())) { mPasswordError.set(mViewAccess.getPasswordErrorMessage()); valid = false; } else { mPasswordError.set(null); } return valid; } @Inject LoginViewModel(); boolean isInputDataValid(); }
|
LoginViewModel extends BaseViewModel { protected boolean isValidatePassword() { boolean valid = true; if (mPasswordValidator != null && !mPasswordValidator.isValid(mPassword.get())) { mPasswordError.set(mViewAccess.getPasswordErrorMessage()); valid = false; } else { mPasswordError.set(null); } return valid; } @Inject LoginViewModel(); boolean isInputDataValid(); final ObservableString mLogin; final ObservableString mLoginError; final ObservableString mPassword; final ObservableString mPasswordError; }
|
@Test public void validatePassword_Error() throws Exception { when(mModel.mPasswordValidator.isValid(any())).thenReturn(false); when(mModel.mViewAccess.getPasswordErrorMessage()).thenReturn("error"); assertThat(mModel.isValidatePassword(), is(false)); assertThat(Strings.isNullOrEmpty(mModel.mPasswordError.get()), is(false)); }
|
protected boolean isValidatePassword() { boolean valid = true; if (mPasswordValidator != null && !mPasswordValidator.isValid(mPassword.get())) { mPasswordError.set(mViewAccess.getPasswordErrorMessage()); valid = false; } else { mPasswordError.set(null); } return valid; }
|
LoginViewModel extends BaseViewModel { protected boolean isValidatePassword() { boolean valid = true; if (mPasswordValidator != null && !mPasswordValidator.isValid(mPassword.get())) { mPasswordError.set(mViewAccess.getPasswordErrorMessage()); valid = false; } else { mPasswordError.set(null); } return valid; } }
|
LoginViewModel extends BaseViewModel { protected boolean isValidatePassword() { boolean valid = true; if (mPasswordValidator != null && !mPasswordValidator.isValid(mPassword.get())) { mPasswordError.set(mViewAccess.getPasswordErrorMessage()); valid = false; } else { mPasswordError.set(null); } return valid; } @Inject LoginViewModel(); }
|
LoginViewModel extends BaseViewModel { protected boolean isValidatePassword() { boolean valid = true; if (mPasswordValidator != null && !mPasswordValidator.isValid(mPassword.get())) { mPasswordError.set(mViewAccess.getPasswordErrorMessage()); valid = false; } else { mPasswordError.set(null); } return valid; } @Inject LoginViewModel(); boolean isInputDataValid(); }
|
LoginViewModel extends BaseViewModel { protected boolean isValidatePassword() { boolean valid = true; if (mPasswordValidator != null && !mPasswordValidator.isValid(mPassword.get())) { mPasswordError.set(mViewAccess.getPasswordErrorMessage()); valid = false; } else { mPasswordError.set(null); } return valid; } @Inject LoginViewModel(); boolean isInputDataValid(); final ObservableString mLogin; final ObservableString mLoginError; final ObservableString mPassword; final ObservableString mPasswordError; }
|
@Test public void isFormValid_Success() throws Exception { when(mModel.mPasswordValidator.isValid(any())).thenReturn(true); when(mModel.mLoginValidator.isValid(any())).thenReturn(true); assertThat(mModel.isInputDataValid(), is(true)); }
|
public boolean isInputDataValid() { return isValidateLogin() && isValidatePassword(); }
|
LoginViewModel extends BaseViewModel { public boolean isInputDataValid() { return isValidateLogin() && isValidatePassword(); } }
|
LoginViewModel extends BaseViewModel { public boolean isInputDataValid() { return isValidateLogin() && isValidatePassword(); } @Inject LoginViewModel(); }
|
LoginViewModel extends BaseViewModel { public boolean isInputDataValid() { return isValidateLogin() && isValidatePassword(); } @Inject LoginViewModel(); boolean isInputDataValid(); }
|
LoginViewModel extends BaseViewModel { public boolean isInputDataValid() { return isValidateLogin() && isValidatePassword(); } @Inject LoginViewModel(); boolean isInputDataValid(); final ObservableString mLogin; final ObservableString mLoginError; final ObservableString mPassword; final ObservableString mPasswordError; }
|
@Test public void isFormValid_Error() throws Exception { when(mModel.mPasswordValidator.isValid(any())).thenReturn(false); when(mModel.mLoginValidator.isValid(any())).thenReturn(true); assertThat(mModel.isInputDataValid(), is(false)); }
|
public boolean isInputDataValid() { return isValidateLogin() && isValidatePassword(); }
|
LoginViewModel extends BaseViewModel { public boolean isInputDataValid() { return isValidateLogin() && isValidatePassword(); } }
|
LoginViewModel extends BaseViewModel { public boolean isInputDataValid() { return isValidateLogin() && isValidatePassword(); } @Inject LoginViewModel(); }
|
LoginViewModel extends BaseViewModel { public boolean isInputDataValid() { return isValidateLogin() && isValidatePassword(); } @Inject LoginViewModel(); boolean isInputDataValid(); }
|
LoginViewModel extends BaseViewModel { public boolean isInputDataValid() { return isValidateLogin() && isValidatePassword(); } @Inject LoginViewModel(); boolean isInputDataValid(); final ObservableString mLogin; final ObservableString mLoginError; final ObservableString mPassword; final ObservableString mPasswordError; }
|
@Test public void setLoginValidator_Correct() throws Exception { Validator validator = new EmailValidator(); mModel.setLoginValidator(validator); assertThat(mModel.mLoginValidator, is(validator)); }
|
protected void setLoginValidator(@Nullable Validator loginValidator) { mLoginValidator = loginValidator; }
|
LoginViewModel extends BaseViewModel { protected void setLoginValidator(@Nullable Validator loginValidator) { mLoginValidator = loginValidator; } }
|
LoginViewModel extends BaseViewModel { protected void setLoginValidator(@Nullable Validator loginValidator) { mLoginValidator = loginValidator; } @Inject LoginViewModel(); }
|
LoginViewModel extends BaseViewModel { protected void setLoginValidator(@Nullable Validator loginValidator) { mLoginValidator = loginValidator; } @Inject LoginViewModel(); boolean isInputDataValid(); }
|
LoginViewModel extends BaseViewModel { protected void setLoginValidator(@Nullable Validator loginValidator) { mLoginValidator = loginValidator; } @Inject LoginViewModel(); boolean isInputDataValid(); final ObservableString mLogin; final ObservableString mLoginError; final ObservableString mPassword; final ObservableString mPasswordError; }
|
@Test public void setLoginValidator_Correct() throws Exception { Validator validator = new EmailValidator(); mModel.setLoginValidator(validator); assertThat(mModel.mLoginValidator, is(validator)); }
|
protected void setLoginValidator(@Nullable Validator loginValidator) { mLoginValidator = loginValidator; }
|
ForgotPasswordViewModel { protected void setLoginValidator(@Nullable Validator loginValidator) { mLoginValidator = loginValidator; } }
|
ForgotPasswordViewModel { protected void setLoginValidator(@Nullable Validator loginValidator) { mLoginValidator = loginValidator; } @Inject ForgotPasswordViewModel(); }
|
ForgotPasswordViewModel { protected void setLoginValidator(@Nullable Validator loginValidator) { mLoginValidator = loginValidator; } @Inject ForgotPasswordViewModel(); boolean isValidateLogin(); }
|
ForgotPasswordViewModel { protected void setLoginValidator(@Nullable Validator loginValidator) { mLoginValidator = loginValidator; } @Inject ForgotPasswordViewModel(); boolean isValidateLogin(); final ObservableString mLogin; final ObservableString mLoginError; }
|
@Test public void setPasswordValidator_Correct() throws Exception { Validator validator = new EmailValidator(); mModel.setPasswordValidator(validator); assertThat(mModel.mPasswordValidator, is(validator)); }
|
protected void setPasswordValidator(@Nullable Validator passwordValidator) { mPasswordValidator = passwordValidator; }
|
LoginViewModel extends BaseViewModel { protected void setPasswordValidator(@Nullable Validator passwordValidator) { mPasswordValidator = passwordValidator; } }
|
LoginViewModel extends BaseViewModel { protected void setPasswordValidator(@Nullable Validator passwordValidator) { mPasswordValidator = passwordValidator; } @Inject LoginViewModel(); }
|
LoginViewModel extends BaseViewModel { protected void setPasswordValidator(@Nullable Validator passwordValidator) { mPasswordValidator = passwordValidator; } @Inject LoginViewModel(); boolean isInputDataValid(); }
|
LoginViewModel extends BaseViewModel { protected void setPasswordValidator(@Nullable Validator passwordValidator) { mPasswordValidator = passwordValidator; } @Inject LoginViewModel(); boolean isInputDataValid(); final ObservableString mLogin; final ObservableString mLoginError; final ObservableString mPassword; final ObservableString mPasswordError; }
|
@Test public void validateLogin_Success() throws Exception { when(mModel.mLoginValidator.isValid(any())).thenReturn(true); assertThat(mModel.isLoginValid(), is(true)); assertThat(Strings.isNullOrEmpty(mModel.mLoginError.get()), is(true)); }
|
protected boolean isLoginValid() { boolean valid = true; if (mLoginValidator != null && !mLoginValidator.isValid(mLogin.get())) { mLoginError.set(mViewAccess.getLoginErrorMessage()); valid = false; } else { mLoginError.set(null); } return valid; }
|
RegisterViewModel extends BaseViewModel { protected boolean isLoginValid() { boolean valid = true; if (mLoginValidator != null && !mLoginValidator.isValid(mLogin.get())) { mLoginError.set(mViewAccess.getLoginErrorMessage()); valid = false; } else { mLoginError.set(null); } return valid; } }
|
RegisterViewModel extends BaseViewModel { protected boolean isLoginValid() { boolean valid = true; if (mLoginValidator != null && !mLoginValidator.isValid(mLogin.get())) { mLoginError.set(mViewAccess.getLoginErrorMessage()); valid = false; } else { mLoginError.set(null); } return valid; } @Inject RegisterViewModel(); }
|
RegisterViewModel extends BaseViewModel { protected boolean isLoginValid() { boolean valid = true; if (mLoginValidator != null && !mLoginValidator.isValid(mLogin.get())) { mLoginError.set(mViewAccess.getLoginErrorMessage()); valid = false; } else { mLoginError.set(null); } return valid; } @Inject RegisterViewModel(); boolean isInputDataValid(); }
|
RegisterViewModel extends BaseViewModel { protected boolean isLoginValid() { boolean valid = true; if (mLoginValidator != null && !mLoginValidator.isValid(mLogin.get())) { mLoginError.set(mViewAccess.getLoginErrorMessage()); valid = false; } else { mLoginError.set(null); } return valid; } @Inject RegisterViewModel(); boolean isInputDataValid(); final ObservableString mLogin; final ObservableString mFirstName; final ObservableString mLastName; final ObservableString mPassword; final ObservableString mConfirmPassword; final ObservableString mLoginError; final ObservableString mFirstNameError; final ObservableString mLastNameError; final ObservableString mPasswordError; final ObservableString mConfirmPasswordError; }
|
@Test public void validateLogin_Error() throws Exception { when(mModel.mLoginValidator.isValid(any())).thenReturn(false); when(mModel.mViewAccess.getLoginErrorMessage()).thenReturn("error"); assertThat(mModel.isLoginValid(), is(false)); assertThat(Strings.isNullOrEmpty(mModel.mLoginError.get()), is(false)); }
|
protected boolean isLoginValid() { boolean valid = true; if (mLoginValidator != null && !mLoginValidator.isValid(mLogin.get())) { mLoginError.set(mViewAccess.getLoginErrorMessage()); valid = false; } else { mLoginError.set(null); } return valid; }
|
RegisterViewModel extends BaseViewModel { protected boolean isLoginValid() { boolean valid = true; if (mLoginValidator != null && !mLoginValidator.isValid(mLogin.get())) { mLoginError.set(mViewAccess.getLoginErrorMessage()); valid = false; } else { mLoginError.set(null); } return valid; } }
|
RegisterViewModel extends BaseViewModel { protected boolean isLoginValid() { boolean valid = true; if (mLoginValidator != null && !mLoginValidator.isValid(mLogin.get())) { mLoginError.set(mViewAccess.getLoginErrorMessage()); valid = false; } else { mLoginError.set(null); } return valid; } @Inject RegisterViewModel(); }
|
RegisterViewModel extends BaseViewModel { protected boolean isLoginValid() { boolean valid = true; if (mLoginValidator != null && !mLoginValidator.isValid(mLogin.get())) { mLoginError.set(mViewAccess.getLoginErrorMessage()); valid = false; } else { mLoginError.set(null); } return valid; } @Inject RegisterViewModel(); boolean isInputDataValid(); }
|
RegisterViewModel extends BaseViewModel { protected boolean isLoginValid() { boolean valid = true; if (mLoginValidator != null && !mLoginValidator.isValid(mLogin.get())) { mLoginError.set(mViewAccess.getLoginErrorMessage()); valid = false; } else { mLoginError.set(null); } return valid; } @Inject RegisterViewModel(); boolean isInputDataValid(); final ObservableString mLogin; final ObservableString mFirstName; final ObservableString mLastName; final ObservableString mPassword; final ObservableString mConfirmPassword; final ObservableString mLoginError; final ObservableString mFirstNameError; final ObservableString mLastNameError; final ObservableString mPasswordError; final ObservableString mConfirmPasswordError; }
|
@Test public void validateFirstName_Success() throws Exception { when(mModel.mFirstNameValidator.isValid(any())).thenReturn(true); assertThat(mModel.isFirstNameValid(), is(true)); assertThat(Strings.isNullOrEmpty(mModel.mFirstNameError.get()), is(true)); }
|
protected boolean isFirstNameValid() { boolean valid = true; if (mFirstNameValidator != null && !mFirstNameValidator.isValid(mFirstName.get())) { mFirstNameError.set(mViewAccess.getFirstNameErrorMessage()); valid = false; } else { mFirstNameError.set(null); } return valid; }
|
RegisterViewModel extends BaseViewModel { protected boolean isFirstNameValid() { boolean valid = true; if (mFirstNameValidator != null && !mFirstNameValidator.isValid(mFirstName.get())) { mFirstNameError.set(mViewAccess.getFirstNameErrorMessage()); valid = false; } else { mFirstNameError.set(null); } return valid; } }
|
RegisterViewModel extends BaseViewModel { protected boolean isFirstNameValid() { boolean valid = true; if (mFirstNameValidator != null && !mFirstNameValidator.isValid(mFirstName.get())) { mFirstNameError.set(mViewAccess.getFirstNameErrorMessage()); valid = false; } else { mFirstNameError.set(null); } return valid; } @Inject RegisterViewModel(); }
|
RegisterViewModel extends BaseViewModel { protected boolean isFirstNameValid() { boolean valid = true; if (mFirstNameValidator != null && !mFirstNameValidator.isValid(mFirstName.get())) { mFirstNameError.set(mViewAccess.getFirstNameErrorMessage()); valid = false; } else { mFirstNameError.set(null); } return valid; } @Inject RegisterViewModel(); boolean isInputDataValid(); }
|
RegisterViewModel extends BaseViewModel { protected boolean isFirstNameValid() { boolean valid = true; if (mFirstNameValidator != null && !mFirstNameValidator.isValid(mFirstName.get())) { mFirstNameError.set(mViewAccess.getFirstNameErrorMessage()); valid = false; } else { mFirstNameError.set(null); } return valid; } @Inject RegisterViewModel(); boolean isInputDataValid(); final ObservableString mLogin; final ObservableString mFirstName; final ObservableString mLastName; final ObservableString mPassword; final ObservableString mConfirmPassword; final ObservableString mLoginError; final ObservableString mFirstNameError; final ObservableString mLastNameError; final ObservableString mPasswordError; final ObservableString mConfirmPasswordError; }
|
@Test public void validateFirstName_Error() throws Exception { when(mModel.mFirstNameValidator.isValid(any())).thenReturn(false); when(mModel.mViewAccess.getFirstNameErrorMessage()).thenReturn("error"); assertThat(mModel.isFirstNameValid(), is(false)); assertThat(Strings.isNullOrEmpty(mModel.mFirstNameError.get()), is(false)); }
|
protected boolean isFirstNameValid() { boolean valid = true; if (mFirstNameValidator != null && !mFirstNameValidator.isValid(mFirstName.get())) { mFirstNameError.set(mViewAccess.getFirstNameErrorMessage()); valid = false; } else { mFirstNameError.set(null); } return valid; }
|
RegisterViewModel extends BaseViewModel { protected boolean isFirstNameValid() { boolean valid = true; if (mFirstNameValidator != null && !mFirstNameValidator.isValid(mFirstName.get())) { mFirstNameError.set(mViewAccess.getFirstNameErrorMessage()); valid = false; } else { mFirstNameError.set(null); } return valid; } }
|
RegisterViewModel extends BaseViewModel { protected boolean isFirstNameValid() { boolean valid = true; if (mFirstNameValidator != null && !mFirstNameValidator.isValid(mFirstName.get())) { mFirstNameError.set(mViewAccess.getFirstNameErrorMessage()); valid = false; } else { mFirstNameError.set(null); } return valid; } @Inject RegisterViewModel(); }
|
RegisterViewModel extends BaseViewModel { protected boolean isFirstNameValid() { boolean valid = true; if (mFirstNameValidator != null && !mFirstNameValidator.isValid(mFirstName.get())) { mFirstNameError.set(mViewAccess.getFirstNameErrorMessage()); valid = false; } else { mFirstNameError.set(null); } return valid; } @Inject RegisterViewModel(); boolean isInputDataValid(); }
|
RegisterViewModel extends BaseViewModel { protected boolean isFirstNameValid() { boolean valid = true; if (mFirstNameValidator != null && !mFirstNameValidator.isValid(mFirstName.get())) { mFirstNameError.set(mViewAccess.getFirstNameErrorMessage()); valid = false; } else { mFirstNameError.set(null); } return valid; } @Inject RegisterViewModel(); boolean isInputDataValid(); final ObservableString mLogin; final ObservableString mFirstName; final ObservableString mLastName; final ObservableString mPassword; final ObservableString mConfirmPassword; final ObservableString mLoginError; final ObservableString mFirstNameError; final ObservableString mLastNameError; final ObservableString mPasswordError; final ObservableString mConfirmPasswordError; }
|
@Test public void validateLastName_Success() throws Exception { when(mModel.mLastNameValidator.isValid(any())).thenReturn(true); assertThat(mModel.isLastNameValid(), is(true)); assertThat(Strings.isNullOrEmpty(mModel.mLastNameError.get()), is(true)); }
|
protected boolean isLastNameValid() { boolean valid = true; if (mLastNameValidator != null && !mLastNameValidator.isValid(mLastName.get())) { mLastNameError.set(mViewAccess.getLastNameErrorMessage()); valid = false; } else { mLastNameError.set(null); } return valid; }
|
RegisterViewModel extends BaseViewModel { protected boolean isLastNameValid() { boolean valid = true; if (mLastNameValidator != null && !mLastNameValidator.isValid(mLastName.get())) { mLastNameError.set(mViewAccess.getLastNameErrorMessage()); valid = false; } else { mLastNameError.set(null); } return valid; } }
|
RegisterViewModel extends BaseViewModel { protected boolean isLastNameValid() { boolean valid = true; if (mLastNameValidator != null && !mLastNameValidator.isValid(mLastName.get())) { mLastNameError.set(mViewAccess.getLastNameErrorMessage()); valid = false; } else { mLastNameError.set(null); } return valid; } @Inject RegisterViewModel(); }
|
RegisterViewModel extends BaseViewModel { protected boolean isLastNameValid() { boolean valid = true; if (mLastNameValidator != null && !mLastNameValidator.isValid(mLastName.get())) { mLastNameError.set(mViewAccess.getLastNameErrorMessage()); valid = false; } else { mLastNameError.set(null); } return valid; } @Inject RegisterViewModel(); boolean isInputDataValid(); }
|
RegisterViewModel extends BaseViewModel { protected boolean isLastNameValid() { boolean valid = true; if (mLastNameValidator != null && !mLastNameValidator.isValid(mLastName.get())) { mLastNameError.set(mViewAccess.getLastNameErrorMessage()); valid = false; } else { mLastNameError.set(null); } return valid; } @Inject RegisterViewModel(); boolean isInputDataValid(); final ObservableString mLogin; final ObservableString mFirstName; final ObservableString mLastName; final ObservableString mPassword; final ObservableString mConfirmPassword; final ObservableString mLoginError; final ObservableString mFirstNameError; final ObservableString mLastNameError; final ObservableString mPasswordError; final ObservableString mConfirmPasswordError; }
|
@Test public void validateLastName_Error() throws Exception { when(mModel.mLastNameValidator.isValid(any())).thenReturn(false); when(mModel.mViewAccess.getLastNameErrorMessage()).thenReturn("error"); assertThat(mModel.isLastNameValid(), is(false)); assertThat(Strings.isNullOrEmpty(mModel.mLastNameError.get()), is(false)); }
|
protected boolean isLastNameValid() { boolean valid = true; if (mLastNameValidator != null && !mLastNameValidator.isValid(mLastName.get())) { mLastNameError.set(mViewAccess.getLastNameErrorMessage()); valid = false; } else { mLastNameError.set(null); } return valid; }
|
RegisterViewModel extends BaseViewModel { protected boolean isLastNameValid() { boolean valid = true; if (mLastNameValidator != null && !mLastNameValidator.isValid(mLastName.get())) { mLastNameError.set(mViewAccess.getLastNameErrorMessage()); valid = false; } else { mLastNameError.set(null); } return valid; } }
|
RegisterViewModel extends BaseViewModel { protected boolean isLastNameValid() { boolean valid = true; if (mLastNameValidator != null && !mLastNameValidator.isValid(mLastName.get())) { mLastNameError.set(mViewAccess.getLastNameErrorMessage()); valid = false; } else { mLastNameError.set(null); } return valid; } @Inject RegisterViewModel(); }
|
RegisterViewModel extends BaseViewModel { protected boolean isLastNameValid() { boolean valid = true; if (mLastNameValidator != null && !mLastNameValidator.isValid(mLastName.get())) { mLastNameError.set(mViewAccess.getLastNameErrorMessage()); valid = false; } else { mLastNameError.set(null); } return valid; } @Inject RegisterViewModel(); boolean isInputDataValid(); }
|
RegisterViewModel extends BaseViewModel { protected boolean isLastNameValid() { boolean valid = true; if (mLastNameValidator != null && !mLastNameValidator.isValid(mLastName.get())) { mLastNameError.set(mViewAccess.getLastNameErrorMessage()); valid = false; } else { mLastNameError.set(null); } return valid; } @Inject RegisterViewModel(); boolean isInputDataValid(); final ObservableString mLogin; final ObservableString mFirstName; final ObservableString mLastName; final ObservableString mPassword; final ObservableString mConfirmPassword; final ObservableString mLoginError; final ObservableString mFirstNameError; final ObservableString mLastNameError; final ObservableString mPasswordError; final ObservableString mConfirmPasswordError; }
|
@Test public void validatePassword_Success() throws Exception { when(mModel.mPasswordValidator.isValid(any())).thenReturn(true); assertThat(mModel.isPasswordValid(), is(true)); assertThat(Strings.isNullOrEmpty(mModel.mPasswordError.get()), is(true)); }
|
protected boolean isPasswordValid() { boolean valid = true; if (mPasswordValidator != null && !mPasswordValidator.isValid(mPassword.get())) { mPasswordError.set(mViewAccess.getPasswordErrorMessage()); valid = false; } else { mPasswordError.set(null); } return valid; }
|
RegisterViewModel extends BaseViewModel { protected boolean isPasswordValid() { boolean valid = true; if (mPasswordValidator != null && !mPasswordValidator.isValid(mPassword.get())) { mPasswordError.set(mViewAccess.getPasswordErrorMessage()); valid = false; } else { mPasswordError.set(null); } return valid; } }
|
RegisterViewModel extends BaseViewModel { protected boolean isPasswordValid() { boolean valid = true; if (mPasswordValidator != null && !mPasswordValidator.isValid(mPassword.get())) { mPasswordError.set(mViewAccess.getPasswordErrorMessage()); valid = false; } else { mPasswordError.set(null); } return valid; } @Inject RegisterViewModel(); }
|
RegisterViewModel extends BaseViewModel { protected boolean isPasswordValid() { boolean valid = true; if (mPasswordValidator != null && !mPasswordValidator.isValid(mPassword.get())) { mPasswordError.set(mViewAccess.getPasswordErrorMessage()); valid = false; } else { mPasswordError.set(null); } return valid; } @Inject RegisterViewModel(); boolean isInputDataValid(); }
|
RegisterViewModel extends BaseViewModel { protected boolean isPasswordValid() { boolean valid = true; if (mPasswordValidator != null && !mPasswordValidator.isValid(mPassword.get())) { mPasswordError.set(mViewAccess.getPasswordErrorMessage()); valid = false; } else { mPasswordError.set(null); } return valid; } @Inject RegisterViewModel(); boolean isInputDataValid(); final ObservableString mLogin; final ObservableString mFirstName; final ObservableString mLastName; final ObservableString mPassword; final ObservableString mConfirmPassword; final ObservableString mLoginError; final ObservableString mFirstNameError; final ObservableString mLastNameError; final ObservableString mPasswordError; final ObservableString mConfirmPasswordError; }
|
@Test public void testStart_Fail() throws Exception { Verticle verticle = create(TestStartFailVerticle.class.getName()); verticle.start(startFuture); verify(startFuture, never()).complete(); verify(startFuture).fail(any(Throwable.class)); }
|
@Override public void start(Future<Void> startedResult) throws Exception { realVerticle.start(startedResult); }
|
HK2VerticleLoader extends AbstractVerticle { @Override public void start(Future<Void> startedResult) throws Exception { realVerticle.start(startedResult); } }
|
HK2VerticleLoader extends AbstractVerticle { @Override public void start(Future<Void> startedResult) throws Exception { realVerticle.start(startedResult); } HK2VerticleLoader(String verticleName, ClassLoader classLoader, ServiceLocator parent); }
|
HK2VerticleLoader extends AbstractVerticle { @Override public void start(Future<Void> startedResult) throws Exception { realVerticle.start(startedResult); } HK2VerticleLoader(String verticleName, ClassLoader classLoader, ServiceLocator parent); @Override void init(Vertx vertx, Context context); @Override void start(Future<Void> startedResult); @Override void stop(Future<Void> stopFuture); String getVerticleName(); Verticle createRealVerticle(); }
|
HK2VerticleLoader extends AbstractVerticle { @Override public void start(Future<Void> startedResult) throws Exception { realVerticle.start(startedResult); } HK2VerticleLoader(String verticleName, ClassLoader classLoader, ServiceLocator parent); @Override void init(Vertx vertx, Context context); @Override void start(Future<Void> startedResult); @Override void stop(Future<Void> stopFuture); String getVerticleName(); Verticle createRealVerticle(); static final String CONFIG_BOOTSTRAP_BINDER_NAME; static final String BOOTSTRAP_BINDER_NAME; }
|
@Test public void testStop_Fail() throws Exception { Verticle verticle = create(TestStopFailVerticle.class.getName()); verticle.stop(stopFuture); verify(stopFuture, never()).complete(); verify(stopFuture).fail(any(Throwable.class)); }
|
@Override public void stop(Future<Void> stopFuture) throws Exception { classLoader = null; parent = null; Future<Void> future = Future.future(); future.setHandler(result -> { ServiceLocatorFactory.getInstance().destroy(locator); locator = null; if (result.succeeded()) { stopFuture.complete(); } else { stopFuture.fail(future.cause()); } }); try { if (realVerticle != null) { realVerticle.stop(future); } else { future.complete(); } } catch (Throwable t) { future.fail(t); } }
|
HK2VerticleLoader extends AbstractVerticle { @Override public void stop(Future<Void> stopFuture) throws Exception { classLoader = null; parent = null; Future<Void> future = Future.future(); future.setHandler(result -> { ServiceLocatorFactory.getInstance().destroy(locator); locator = null; if (result.succeeded()) { stopFuture.complete(); } else { stopFuture.fail(future.cause()); } }); try { if (realVerticle != null) { realVerticle.stop(future); } else { future.complete(); } } catch (Throwable t) { future.fail(t); } } }
|
HK2VerticleLoader extends AbstractVerticle { @Override public void stop(Future<Void> stopFuture) throws Exception { classLoader = null; parent = null; Future<Void> future = Future.future(); future.setHandler(result -> { ServiceLocatorFactory.getInstance().destroy(locator); locator = null; if (result.succeeded()) { stopFuture.complete(); } else { stopFuture.fail(future.cause()); } }); try { if (realVerticle != null) { realVerticle.stop(future); } else { future.complete(); } } catch (Throwable t) { future.fail(t); } } HK2VerticleLoader(String verticleName, ClassLoader classLoader, ServiceLocator parent); }
|
HK2VerticleLoader extends AbstractVerticle { @Override public void stop(Future<Void> stopFuture) throws Exception { classLoader = null; parent = null; Future<Void> future = Future.future(); future.setHandler(result -> { ServiceLocatorFactory.getInstance().destroy(locator); locator = null; if (result.succeeded()) { stopFuture.complete(); } else { stopFuture.fail(future.cause()); } }); try { if (realVerticle != null) { realVerticle.stop(future); } else { future.complete(); } } catch (Throwable t) { future.fail(t); } } HK2VerticleLoader(String verticleName, ClassLoader classLoader, ServiceLocator parent); @Override void init(Vertx vertx, Context context); @Override void start(Future<Void> startedResult); @Override void stop(Future<Void> stopFuture); String getVerticleName(); Verticle createRealVerticle(); }
|
HK2VerticleLoader extends AbstractVerticle { @Override public void stop(Future<Void> stopFuture) throws Exception { classLoader = null; parent = null; Future<Void> future = Future.future(); future.setHandler(result -> { ServiceLocatorFactory.getInstance().destroy(locator); locator = null; if (result.succeeded()) { stopFuture.complete(); } else { stopFuture.fail(future.cause()); } }); try { if (realVerticle != null) { realVerticle.stop(future); } else { future.complete(); } } catch (Throwable t) { future.fail(t); } } HK2VerticleLoader(String verticleName, ClassLoader classLoader, ServiceLocator parent); @Override void init(Vertx vertx, Context context); @Override void start(Future<Void> startedResult); @Override void stop(Future<Void> stopFuture); String getVerticleName(); Verticle createRealVerticle(); static final String CONFIG_BOOTSTRAP_BINDER_NAME; static final String BOOTSTRAP_BINDER_NAME; }
|
@Test public void testStop_Throw() throws Exception { Verticle verticle = create(TestStopThrowVerticle.class.getName()); verticle.stop(stopFuture); verify(stopFuture, never()).complete(); verify(stopFuture).fail(any(Throwable.class)); }
|
@Override public void stop(Future<Void> stopFuture) throws Exception { classLoader = null; parent = null; Future<Void> future = Future.future(); future.setHandler(result -> { ServiceLocatorFactory.getInstance().destroy(locator); locator = null; if (result.succeeded()) { stopFuture.complete(); } else { stopFuture.fail(future.cause()); } }); try { if (realVerticle != null) { realVerticle.stop(future); } else { future.complete(); } } catch (Throwable t) { future.fail(t); } }
|
HK2VerticleLoader extends AbstractVerticle { @Override public void stop(Future<Void> stopFuture) throws Exception { classLoader = null; parent = null; Future<Void> future = Future.future(); future.setHandler(result -> { ServiceLocatorFactory.getInstance().destroy(locator); locator = null; if (result.succeeded()) { stopFuture.complete(); } else { stopFuture.fail(future.cause()); } }); try { if (realVerticle != null) { realVerticle.stop(future); } else { future.complete(); } } catch (Throwable t) { future.fail(t); } } }
|
HK2VerticleLoader extends AbstractVerticle { @Override public void stop(Future<Void> stopFuture) throws Exception { classLoader = null; parent = null; Future<Void> future = Future.future(); future.setHandler(result -> { ServiceLocatorFactory.getInstance().destroy(locator); locator = null; if (result.succeeded()) { stopFuture.complete(); } else { stopFuture.fail(future.cause()); } }); try { if (realVerticle != null) { realVerticle.stop(future); } else { future.complete(); } } catch (Throwable t) { future.fail(t); } } HK2VerticleLoader(String verticleName, ClassLoader classLoader, ServiceLocator parent); }
|
HK2VerticleLoader extends AbstractVerticle { @Override public void stop(Future<Void> stopFuture) throws Exception { classLoader = null; parent = null; Future<Void> future = Future.future(); future.setHandler(result -> { ServiceLocatorFactory.getInstance().destroy(locator); locator = null; if (result.succeeded()) { stopFuture.complete(); } else { stopFuture.fail(future.cause()); } }); try { if (realVerticle != null) { realVerticle.stop(future); } else { future.complete(); } } catch (Throwable t) { future.fail(t); } } HK2VerticleLoader(String verticleName, ClassLoader classLoader, ServiceLocator parent); @Override void init(Vertx vertx, Context context); @Override void start(Future<Void> startedResult); @Override void stop(Future<Void> stopFuture); String getVerticleName(); Verticle createRealVerticle(); }
|
HK2VerticleLoader extends AbstractVerticle { @Override public void stop(Future<Void> stopFuture) throws Exception { classLoader = null; parent = null; Future<Void> future = Future.future(); future.setHandler(result -> { ServiceLocatorFactory.getInstance().destroy(locator); locator = null; if (result.succeeded()) { stopFuture.complete(); } else { stopFuture.fail(future.cause()); } }); try { if (realVerticle != null) { realVerticle.stop(future); } else { future.complete(); } } catch (Throwable t) { future.fail(t); } } HK2VerticleLoader(String verticleName, ClassLoader classLoader, ServiceLocator parent); @Override void init(Vertx vertx, Context context); @Override void start(Future<Void> startedResult); @Override void stop(Future<Void> stopFuture); String getVerticleName(); Verticle createRealVerticle(); static final String CONFIG_BOOTSTRAP_BINDER_NAME; static final String BOOTSTRAP_BINDER_NAME; }
|
@Test public void testPrefix() { assertEquals("java-hk2", factory.prefix()); }
|
@Override public String prefix() { return PREFIX; }
|
HK2VerticleFactory implements VerticleFactory { @Override public String prefix() { return PREFIX; } }
|
HK2VerticleFactory implements VerticleFactory { @Override public String prefix() { return PREFIX; } }
|
HK2VerticleFactory implements VerticleFactory { @Override public String prefix() { return PREFIX; } @Override String prefix(); @Override void close(); ServiceLocator getLocator(); HK2VerticleFactory setLocator(ServiceLocator locator); @Override Verticle createVerticle(String verticleName, ClassLoader classLoader); static String getIdentifier(Class<? extends Verticle> clazz); static String getIdentifier(String clazz); }
|
HK2VerticleFactory implements VerticleFactory { @Override public String prefix() { return PREFIX; } @Override String prefix(); @Override void close(); ServiceLocator getLocator(); HK2VerticleFactory setLocator(ServiceLocator locator); @Override Verticle createVerticle(String verticleName, ClassLoader classLoader); static String getIdentifier(Class<? extends Verticle> clazz); static String getIdentifier(String clazz); static final String PREFIX; }
|
@Test public void testCreateVerticle() throws Exception { String identifier = HK2VerticleFactory.getIdentifier(TestHK2Verticle.class); Verticle verticle = factory.createVerticle(identifier, this.getClass().getClassLoader()); assertThat(verticle, instanceOf(HK2VerticleLoader.class)); HK2VerticleLoader loader = (HK2VerticleLoader) verticle; assertEquals(TestHK2Verticle.class.getName(), loader.getVerticleName()); }
|
@Override public Verticle createVerticle(String verticleName, ClassLoader classLoader) throws Exception { verticleName = VerticleFactory.removePrefix(verticleName); @SuppressWarnings("unchecked") Class<Verticle> loader = (Class<Verticle>) classLoader.loadClass(HK2VerticleLoader.class.getName()); Constructor<Verticle> ctor = loader.getConstructor(String.class, ClassLoader.class, ServiceLocator.class); if (ctor == null) { throw new IllegalStateException("Could not find HK2VerticleLoad constructor"); } return ctor.newInstance(verticleName, classLoader, getLocator()); }
|
HK2VerticleFactory implements VerticleFactory { @Override public Verticle createVerticle(String verticleName, ClassLoader classLoader) throws Exception { verticleName = VerticleFactory.removePrefix(verticleName); @SuppressWarnings("unchecked") Class<Verticle> loader = (Class<Verticle>) classLoader.loadClass(HK2VerticleLoader.class.getName()); Constructor<Verticle> ctor = loader.getConstructor(String.class, ClassLoader.class, ServiceLocator.class); if (ctor == null) { throw new IllegalStateException("Could not find HK2VerticleLoad constructor"); } return ctor.newInstance(verticleName, classLoader, getLocator()); } }
|
HK2VerticleFactory implements VerticleFactory { @Override public Verticle createVerticle(String verticleName, ClassLoader classLoader) throws Exception { verticleName = VerticleFactory.removePrefix(verticleName); @SuppressWarnings("unchecked") Class<Verticle> loader = (Class<Verticle>) classLoader.loadClass(HK2VerticleLoader.class.getName()); Constructor<Verticle> ctor = loader.getConstructor(String.class, ClassLoader.class, ServiceLocator.class); if (ctor == null) { throw new IllegalStateException("Could not find HK2VerticleLoad constructor"); } return ctor.newInstance(verticleName, classLoader, getLocator()); } }
|
HK2VerticleFactory implements VerticleFactory { @Override public Verticle createVerticle(String verticleName, ClassLoader classLoader) throws Exception { verticleName = VerticleFactory.removePrefix(verticleName); @SuppressWarnings("unchecked") Class<Verticle> loader = (Class<Verticle>) classLoader.loadClass(HK2VerticleLoader.class.getName()); Constructor<Verticle> ctor = loader.getConstructor(String.class, ClassLoader.class, ServiceLocator.class); if (ctor == null) { throw new IllegalStateException("Could not find HK2VerticleLoad constructor"); } return ctor.newInstance(verticleName, classLoader, getLocator()); } @Override String prefix(); @Override void close(); ServiceLocator getLocator(); HK2VerticleFactory setLocator(ServiceLocator locator); @Override Verticle createVerticle(String verticleName, ClassLoader classLoader); static String getIdentifier(Class<? extends Verticle> clazz); static String getIdentifier(String clazz); }
|
HK2VerticleFactory implements VerticleFactory { @Override public Verticle createVerticle(String verticleName, ClassLoader classLoader) throws Exception { verticleName = VerticleFactory.removePrefix(verticleName); @SuppressWarnings("unchecked") Class<Verticle> loader = (Class<Verticle>) classLoader.loadClass(HK2VerticleLoader.class.getName()); Constructor<Verticle> ctor = loader.getConstructor(String.class, ClassLoader.class, ServiceLocator.class); if (ctor == null) { throw new IllegalStateException("Could not find HK2VerticleLoad constructor"); } return ctor.newInstance(verticleName, classLoader, getLocator()); } @Override String prefix(); @Override void close(); ServiceLocator getLocator(); HK2VerticleFactory setLocator(ServiceLocator locator); @Override Verticle createVerticle(String verticleName, ClassLoader classLoader); static String getIdentifier(Class<? extends Verticle> clazz); static String getIdentifier(String clazz); static final String PREFIX; }
|
@Test public void testSetLocator() throws Exception { ServiceLocator original = factory.getLocator(); assertNull(original); ServiceLocator locator = mock(ServiceLocator.class); factory.setLocator(locator); assertEquals(locator, factory.getLocator()); }
|
public HK2VerticleFactory setLocator(ServiceLocator locator) { this.locator = locator; return this; }
|
HK2VerticleFactory implements VerticleFactory { public HK2VerticleFactory setLocator(ServiceLocator locator) { this.locator = locator; return this; } }
|
HK2VerticleFactory implements VerticleFactory { public HK2VerticleFactory setLocator(ServiceLocator locator) { this.locator = locator; return this; } }
|
HK2VerticleFactory implements VerticleFactory { public HK2VerticleFactory setLocator(ServiceLocator locator) { this.locator = locator; return this; } @Override String prefix(); @Override void close(); ServiceLocator getLocator(); HK2VerticleFactory setLocator(ServiceLocator locator); @Override Verticle createVerticle(String verticleName, ClassLoader classLoader); static String getIdentifier(Class<? extends Verticle> clazz); static String getIdentifier(String clazz); }
|
HK2VerticleFactory implements VerticleFactory { public HK2VerticleFactory setLocator(ServiceLocator locator) { this.locator = locator; return this; } @Override String prefix(); @Override void close(); ServiceLocator getLocator(); HK2VerticleFactory setLocator(ServiceLocator locator); @Override Verticle createVerticle(String verticleName, ClassLoader classLoader); static String getIdentifier(Class<? extends Verticle> clazz); static String getIdentifier(String clazz); static final String PREFIX; }
|
@Test public void testClose() throws Exception { ServiceLocator locator = mock(ServiceLocator.class); factory.setLocator(locator); factory.close(); verify(locator).shutdown(); }
|
@Override public void close() { if (locator != null) { ServiceLocatorFactory.getInstance().destroy(locator); locator = null; } }
|
HK2VerticleFactory implements VerticleFactory { @Override public void close() { if (locator != null) { ServiceLocatorFactory.getInstance().destroy(locator); locator = null; } } }
|
HK2VerticleFactory implements VerticleFactory { @Override public void close() { if (locator != null) { ServiceLocatorFactory.getInstance().destroy(locator); locator = null; } } }
|
HK2VerticleFactory implements VerticleFactory { @Override public void close() { if (locator != null) { ServiceLocatorFactory.getInstance().destroy(locator); locator = null; } } @Override String prefix(); @Override void close(); ServiceLocator getLocator(); HK2VerticleFactory setLocator(ServiceLocator locator); @Override Verticle createVerticle(String verticleName, ClassLoader classLoader); static String getIdentifier(Class<? extends Verticle> clazz); static String getIdentifier(String clazz); }
|
HK2VerticleFactory implements VerticleFactory { @Override public void close() { if (locator != null) { ServiceLocatorFactory.getInstance().destroy(locator); locator = null; } } @Override String prefix(); @Override void close(); ServiceLocator getLocator(); HK2VerticleFactory setLocator(ServiceLocator locator); @Override Verticle createVerticle(String verticleName, ClassLoader classLoader); static String getIdentifier(Class<? extends Verticle> clazz); static String getIdentifier(String clazz); static final String PREFIX; }
|
@Test public void testConfigure() throws Exception { InternalVertxJerseyBinder binder = new InternalVertxJerseyBinder(mock(Vertx.class)); DynamicConfiguration dynamicConfiguration = mock(DynamicConfiguration.class); binder.bind(dynamicConfiguration); }
|
@Override protected void configure() { bind(vertx).to(Vertx.class); bindFactory(VertxRequestReferencingFactory.class).to(HttpServerRequest.class).in(PerLookup.class); bindFactory(VertxRequestReferencingFactory.class).to(new TypeLiteral<ReadStream<HttpServerRequest>>() { }).in(PerLookup.class); bindFactory(ReferencingFactory.<HttpServerRequest>referenceFactory()).to(new TypeLiteral<Ref<HttpServerRequest>>() { }).in(RequestScoped.class); bindFactory(VertxResponseReferencingFactory.class).to(HttpServerResponse.class).in(PerLookup.class); bindFactory(ReferencingFactory.<HttpServerResponse>referenceFactory()).to(new TypeLiteral<Ref<HttpServerResponse>>() { }).in(RequestScoped.class); }
|
InternalVertxJerseyBinder extends AbstractBinder { @Override protected void configure() { bind(vertx).to(Vertx.class); bindFactory(VertxRequestReferencingFactory.class).to(HttpServerRequest.class).in(PerLookup.class); bindFactory(VertxRequestReferencingFactory.class).to(new TypeLiteral<ReadStream<HttpServerRequest>>() { }).in(PerLookup.class); bindFactory(ReferencingFactory.<HttpServerRequest>referenceFactory()).to(new TypeLiteral<Ref<HttpServerRequest>>() { }).in(RequestScoped.class); bindFactory(VertxResponseReferencingFactory.class).to(HttpServerResponse.class).in(PerLookup.class); bindFactory(ReferencingFactory.<HttpServerResponse>referenceFactory()).to(new TypeLiteral<Ref<HttpServerResponse>>() { }).in(RequestScoped.class); } }
|
InternalVertxJerseyBinder extends AbstractBinder { @Override protected void configure() { bind(vertx).to(Vertx.class); bindFactory(VertxRequestReferencingFactory.class).to(HttpServerRequest.class).in(PerLookup.class); bindFactory(VertxRequestReferencingFactory.class).to(new TypeLiteral<ReadStream<HttpServerRequest>>() { }).in(PerLookup.class); bindFactory(ReferencingFactory.<HttpServerRequest>referenceFactory()).to(new TypeLiteral<Ref<HttpServerRequest>>() { }).in(RequestScoped.class); bindFactory(VertxResponseReferencingFactory.class).to(HttpServerResponse.class).in(PerLookup.class); bindFactory(ReferencingFactory.<HttpServerResponse>referenceFactory()).to(new TypeLiteral<Ref<HttpServerResponse>>() { }).in(RequestScoped.class); } InternalVertxJerseyBinder(Vertx vertx); }
|
InternalVertxJerseyBinder extends AbstractBinder { @Override protected void configure() { bind(vertx).to(Vertx.class); bindFactory(VertxRequestReferencingFactory.class).to(HttpServerRequest.class).in(PerLookup.class); bindFactory(VertxRequestReferencingFactory.class).to(new TypeLiteral<ReadStream<HttpServerRequest>>() { }).in(PerLookup.class); bindFactory(ReferencingFactory.<HttpServerRequest>referenceFactory()).to(new TypeLiteral<Ref<HttpServerRequest>>() { }).in(RequestScoped.class); bindFactory(VertxResponseReferencingFactory.class).to(HttpServerResponse.class).in(PerLookup.class); bindFactory(ReferencingFactory.<HttpServerResponse>referenceFactory()).to(new TypeLiteral<Ref<HttpServerResponse>>() { }).in(RequestScoped.class); } InternalVertxJerseyBinder(Vertx vertx); }
|
InternalVertxJerseyBinder extends AbstractBinder { @Override protected void configure() { bind(vertx).to(Vertx.class); bindFactory(VertxRequestReferencingFactory.class).to(HttpServerRequest.class).in(PerLookup.class); bindFactory(VertxRequestReferencingFactory.class).to(new TypeLiteral<ReadStream<HttpServerRequest>>() { }).in(PerLookup.class); bindFactory(ReferencingFactory.<HttpServerRequest>referenceFactory()).to(new TypeLiteral<Ref<HttpServerRequest>>() { }).in(RequestScoped.class); bindFactory(VertxResponseReferencingFactory.class).to(HttpServerResponse.class).in(PerLookup.class); bindFactory(ReferencingFactory.<HttpServerResponse>referenceFactory()).to(new TypeLiteral<Ref<HttpServerResponse>>() { }).in(RequestScoped.class); } InternalVertxJerseyBinder(Vertx vertx); }
|
@Test public void testGetMaxBodySize() throws Exception { int expected = DefaultJerseyOptions.DEFAULT_MAX_BODY_SIZE; int maxBodySize; maxBodySize = options.getMaxBodySize(); assertEquals(expected, maxBodySize); expected = 12; config.put(DefaultJerseyOptions.CONFIG_MAX_BODY_SIZE, expected); maxBodySize = options.getMaxBodySize(); assertEquals(expected, maxBodySize); }
|
@Override public int getMaxBodySize() { return config.getInteger(CONFIG_MAX_BODY_SIZE, DEFAULT_MAX_BODY_SIZE); }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public int getMaxBodySize() { return config.getInteger(CONFIG_MAX_BODY_SIZE, DEFAULT_MAX_BODY_SIZE); } }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public int getMaxBodySize() { return config.getInteger(CONFIG_MAX_BODY_SIZE, DEFAULT_MAX_BODY_SIZE); } @Inject DefaultJerseyOptions(Vertx vertx); DefaultJerseyOptions(JsonObject config); }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public int getMaxBodySize() { return config.getInteger(CONFIG_MAX_BODY_SIZE, DEFAULT_MAX_BODY_SIZE); } @Inject DefaultJerseyOptions(Vertx vertx); DefaultJerseyOptions(JsonObject config); @Override List<String> getPackages(); @Override Map<String, Object> getProperties(); @Override Set<Class<?>> getComponents(); @Override Set<Object> getInstances(); String getHost(); int getPort(); boolean getSSL(); JksOptions getKeyStoreOptions(); Integer getReceiveBufferSize(); int getAcceptBacklog(); @Override URI getBaseUri(); @Override int getMaxBodySize(); boolean getCompressionSupported(); @Override HttpServerOptions getServerOptions(); }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public int getMaxBodySize() { return config.getInteger(CONFIG_MAX_BODY_SIZE, DEFAULT_MAX_BODY_SIZE); } @Inject DefaultJerseyOptions(Vertx vertx); DefaultJerseyOptions(JsonObject config); @Override List<String> getPackages(); @Override Map<String, Object> getProperties(); @Override Set<Class<?>> getComponents(); @Override Set<Object> getInstances(); String getHost(); int getPort(); boolean getSSL(); JksOptions getKeyStoreOptions(); Integer getReceiveBufferSize(); int getAcceptBacklog(); @Override URI getBaseUri(); @Override int getMaxBodySize(); boolean getCompressionSupported(); @Override HttpServerOptions getServerOptions(); final static String CONFIG_HOST; final static String CONFIG_PORT; final static String CONFIG_SSL; final static String CONFIG_JKS_OPTIONS; final static String CONFIG_RECEIVE_BUFFER_SIZE; final static String CONFIG_BACKLOG_SIZE; final static String CONFIG_RESOURCE_CONFIG; final static String CONFIG_PROPERTIES; final static String CONFIG_COMPRESSION_SUPPORTED; static final String CONFIG_BASE_PATH; static final String CONFIG_MAX_BODY_SIZE; static final String CONFIG_RESOURCES; static final String CONFIG_PACKAGES; static final String CONFIG_FEATURES; static final String CONFIG_COMPONENTS; static final String CONFIG_BINDERS; static final String CONFIG_INSTANCES; static final int DEFAULT_MAX_BODY_SIZE; }
|
@Test public void testGetPackages() throws Exception { String package1 = "com.englishtown.vertx.jersey.resources1"; String package2 = "com.englishtown.vertx.jersey.resources2"; config.put(DefaultJerseyOptions.CONFIG_RESOURCES, new JsonArray().add(package1)); config.put(DefaultJerseyOptions.CONFIG_PACKAGES, new JsonArray().add(package2)); List<String> packages = options.getPackages(); assertNotNull(packages); assertEquals(2, packages.size()); assertEquals(package1, packages.get(0)); assertEquals(package2, packages.get(1)); }
|
@Override public List<String> getPackages() { List<String> list = new ArrayList<>(); Consumer<JsonArray> reader = array -> { if ((array != null && !array.isEmpty())) { for (int i = 0; i < array.size(); i++) { list.add(array.getString(i)); } } }; JsonArray resources = config.getJsonArray(CONFIG_RESOURCES, null); JsonArray packages = config.getJsonArray(CONFIG_PACKAGES, null); reader.accept(resources); reader.accept(packages); return list; }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public List<String> getPackages() { List<String> list = new ArrayList<>(); Consumer<JsonArray> reader = array -> { if ((array != null && !array.isEmpty())) { for (int i = 0; i < array.size(); i++) { list.add(array.getString(i)); } } }; JsonArray resources = config.getJsonArray(CONFIG_RESOURCES, null); JsonArray packages = config.getJsonArray(CONFIG_PACKAGES, null); reader.accept(resources); reader.accept(packages); return list; } }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public List<String> getPackages() { List<String> list = new ArrayList<>(); Consumer<JsonArray> reader = array -> { if ((array != null && !array.isEmpty())) { for (int i = 0; i < array.size(); i++) { list.add(array.getString(i)); } } }; JsonArray resources = config.getJsonArray(CONFIG_RESOURCES, null); JsonArray packages = config.getJsonArray(CONFIG_PACKAGES, null); reader.accept(resources); reader.accept(packages); return list; } @Inject DefaultJerseyOptions(Vertx vertx); DefaultJerseyOptions(JsonObject config); }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public List<String> getPackages() { List<String> list = new ArrayList<>(); Consumer<JsonArray> reader = array -> { if ((array != null && !array.isEmpty())) { for (int i = 0; i < array.size(); i++) { list.add(array.getString(i)); } } }; JsonArray resources = config.getJsonArray(CONFIG_RESOURCES, null); JsonArray packages = config.getJsonArray(CONFIG_PACKAGES, null); reader.accept(resources); reader.accept(packages); return list; } @Inject DefaultJerseyOptions(Vertx vertx); DefaultJerseyOptions(JsonObject config); @Override List<String> getPackages(); @Override Map<String, Object> getProperties(); @Override Set<Class<?>> getComponents(); @Override Set<Object> getInstances(); String getHost(); int getPort(); boolean getSSL(); JksOptions getKeyStoreOptions(); Integer getReceiveBufferSize(); int getAcceptBacklog(); @Override URI getBaseUri(); @Override int getMaxBodySize(); boolean getCompressionSupported(); @Override HttpServerOptions getServerOptions(); }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public List<String> getPackages() { List<String> list = new ArrayList<>(); Consumer<JsonArray> reader = array -> { if ((array != null && !array.isEmpty())) { for (int i = 0; i < array.size(); i++) { list.add(array.getString(i)); } } }; JsonArray resources = config.getJsonArray(CONFIG_RESOURCES, null); JsonArray packages = config.getJsonArray(CONFIG_PACKAGES, null); reader.accept(resources); reader.accept(packages); return list; } @Inject DefaultJerseyOptions(Vertx vertx); DefaultJerseyOptions(JsonObject config); @Override List<String> getPackages(); @Override Map<String, Object> getProperties(); @Override Set<Class<?>> getComponents(); @Override Set<Object> getInstances(); String getHost(); int getPort(); boolean getSSL(); JksOptions getKeyStoreOptions(); Integer getReceiveBufferSize(); int getAcceptBacklog(); @Override URI getBaseUri(); @Override int getMaxBodySize(); boolean getCompressionSupported(); @Override HttpServerOptions getServerOptions(); final static String CONFIG_HOST; final static String CONFIG_PORT; final static String CONFIG_SSL; final static String CONFIG_JKS_OPTIONS; final static String CONFIG_RECEIVE_BUFFER_SIZE; final static String CONFIG_BACKLOG_SIZE; final static String CONFIG_RESOURCE_CONFIG; final static String CONFIG_PROPERTIES; final static String CONFIG_COMPRESSION_SUPPORTED; static final String CONFIG_BASE_PATH; static final String CONFIG_MAX_BODY_SIZE; static final String CONFIG_RESOURCES; static final String CONFIG_PACKAGES; static final String CONFIG_FEATURES; static final String CONFIG_COMPONENTS; static final String CONFIG_BINDERS; static final String CONFIG_INSTANCES; static final int DEFAULT_MAX_BODY_SIZE; }
|
@Test public void testGetComponents() throws Exception { config.put(DefaultJerseyOptions.CONFIG_COMPONENTS, new JsonArray().add(MyObj.class.getName())); config.put(DefaultJerseyOptions.CONFIG_FEATURES, new JsonArray().add(MyBinder.class.getName())); Set<Class<?>> instances = options.getComponents(); assertNotNull(instances); assertEquals(2, instances.size()); assertTrue(instances.contains(MyObj.class)); assertTrue(instances.contains(MyBinder.class)); }
|
@Override public Set<Class<?>> getComponents() { Set<Class<?>> set = new HashSet<>(); ClassLoader cl = Thread.currentThread().getContextClassLoader(); Consumer<JsonArray> reader = array -> { if (array != null && array.size() > 0) { for (int i = 0; i < array.size(); i++) { try { set.add(cl.loadClass(array.getString(i))); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } } } }; JsonArray features = config.getJsonArray(CONFIG_FEATURES, null); JsonArray components = config.getJsonArray(CONFIG_COMPONENTS, null); reader.accept(features); reader.accept(components); return set; }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public Set<Class<?>> getComponents() { Set<Class<?>> set = new HashSet<>(); ClassLoader cl = Thread.currentThread().getContextClassLoader(); Consumer<JsonArray> reader = array -> { if (array != null && array.size() > 0) { for (int i = 0; i < array.size(); i++) { try { set.add(cl.loadClass(array.getString(i))); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } } } }; JsonArray features = config.getJsonArray(CONFIG_FEATURES, null); JsonArray components = config.getJsonArray(CONFIG_COMPONENTS, null); reader.accept(features); reader.accept(components); return set; } }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public Set<Class<?>> getComponents() { Set<Class<?>> set = new HashSet<>(); ClassLoader cl = Thread.currentThread().getContextClassLoader(); Consumer<JsonArray> reader = array -> { if (array != null && array.size() > 0) { for (int i = 0; i < array.size(); i++) { try { set.add(cl.loadClass(array.getString(i))); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } } } }; JsonArray features = config.getJsonArray(CONFIG_FEATURES, null); JsonArray components = config.getJsonArray(CONFIG_COMPONENTS, null); reader.accept(features); reader.accept(components); return set; } @Inject DefaultJerseyOptions(Vertx vertx); DefaultJerseyOptions(JsonObject config); }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public Set<Class<?>> getComponents() { Set<Class<?>> set = new HashSet<>(); ClassLoader cl = Thread.currentThread().getContextClassLoader(); Consumer<JsonArray> reader = array -> { if (array != null && array.size() > 0) { for (int i = 0; i < array.size(); i++) { try { set.add(cl.loadClass(array.getString(i))); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } } } }; JsonArray features = config.getJsonArray(CONFIG_FEATURES, null); JsonArray components = config.getJsonArray(CONFIG_COMPONENTS, null); reader.accept(features); reader.accept(components); return set; } @Inject DefaultJerseyOptions(Vertx vertx); DefaultJerseyOptions(JsonObject config); @Override List<String> getPackages(); @Override Map<String, Object> getProperties(); @Override Set<Class<?>> getComponents(); @Override Set<Object> getInstances(); String getHost(); int getPort(); boolean getSSL(); JksOptions getKeyStoreOptions(); Integer getReceiveBufferSize(); int getAcceptBacklog(); @Override URI getBaseUri(); @Override int getMaxBodySize(); boolean getCompressionSupported(); @Override HttpServerOptions getServerOptions(); }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public Set<Class<?>> getComponents() { Set<Class<?>> set = new HashSet<>(); ClassLoader cl = Thread.currentThread().getContextClassLoader(); Consumer<JsonArray> reader = array -> { if (array != null && array.size() > 0) { for (int i = 0; i < array.size(); i++) { try { set.add(cl.loadClass(array.getString(i))); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } } } }; JsonArray features = config.getJsonArray(CONFIG_FEATURES, null); JsonArray components = config.getJsonArray(CONFIG_COMPONENTS, null); reader.accept(features); reader.accept(components); return set; } @Inject DefaultJerseyOptions(Vertx vertx); DefaultJerseyOptions(JsonObject config); @Override List<String> getPackages(); @Override Map<String, Object> getProperties(); @Override Set<Class<?>> getComponents(); @Override Set<Object> getInstances(); String getHost(); int getPort(); boolean getSSL(); JksOptions getKeyStoreOptions(); Integer getReceiveBufferSize(); int getAcceptBacklog(); @Override URI getBaseUri(); @Override int getMaxBodySize(); boolean getCompressionSupported(); @Override HttpServerOptions getServerOptions(); final static String CONFIG_HOST; final static String CONFIG_PORT; final static String CONFIG_SSL; final static String CONFIG_JKS_OPTIONS; final static String CONFIG_RECEIVE_BUFFER_SIZE; final static String CONFIG_BACKLOG_SIZE; final static String CONFIG_RESOURCE_CONFIG; final static String CONFIG_PROPERTIES; final static String CONFIG_COMPRESSION_SUPPORTED; static final String CONFIG_BASE_PATH; static final String CONFIG_MAX_BODY_SIZE; static final String CONFIG_RESOURCES; static final String CONFIG_PACKAGES; static final String CONFIG_FEATURES; static final String CONFIG_COMPONENTS; static final String CONFIG_BINDERS; static final String CONFIG_INSTANCES; static final int DEFAULT_MAX_BODY_SIZE; }
|
@Test(expected = RuntimeException.class) public void testGetComponents_Fail() throws Exception { config.put(DefaultJerseyOptions.CONFIG_COMPONENTS, new JsonArray().add(MyObj.class.getName() + ".invalid")); options.getComponents(); fail(); }
|
@Override public Set<Class<?>> getComponents() { Set<Class<?>> set = new HashSet<>(); ClassLoader cl = Thread.currentThread().getContextClassLoader(); Consumer<JsonArray> reader = array -> { if (array != null && array.size() > 0) { for (int i = 0; i < array.size(); i++) { try { set.add(cl.loadClass(array.getString(i))); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } } } }; JsonArray features = config.getJsonArray(CONFIG_FEATURES, null); JsonArray components = config.getJsonArray(CONFIG_COMPONENTS, null); reader.accept(features); reader.accept(components); return set; }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public Set<Class<?>> getComponents() { Set<Class<?>> set = new HashSet<>(); ClassLoader cl = Thread.currentThread().getContextClassLoader(); Consumer<JsonArray> reader = array -> { if (array != null && array.size() > 0) { for (int i = 0; i < array.size(); i++) { try { set.add(cl.loadClass(array.getString(i))); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } } } }; JsonArray features = config.getJsonArray(CONFIG_FEATURES, null); JsonArray components = config.getJsonArray(CONFIG_COMPONENTS, null); reader.accept(features); reader.accept(components); return set; } }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public Set<Class<?>> getComponents() { Set<Class<?>> set = new HashSet<>(); ClassLoader cl = Thread.currentThread().getContextClassLoader(); Consumer<JsonArray> reader = array -> { if (array != null && array.size() > 0) { for (int i = 0; i < array.size(); i++) { try { set.add(cl.loadClass(array.getString(i))); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } } } }; JsonArray features = config.getJsonArray(CONFIG_FEATURES, null); JsonArray components = config.getJsonArray(CONFIG_COMPONENTS, null); reader.accept(features); reader.accept(components); return set; } @Inject DefaultJerseyOptions(Vertx vertx); DefaultJerseyOptions(JsonObject config); }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public Set<Class<?>> getComponents() { Set<Class<?>> set = new HashSet<>(); ClassLoader cl = Thread.currentThread().getContextClassLoader(); Consumer<JsonArray> reader = array -> { if (array != null && array.size() > 0) { for (int i = 0; i < array.size(); i++) { try { set.add(cl.loadClass(array.getString(i))); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } } } }; JsonArray features = config.getJsonArray(CONFIG_FEATURES, null); JsonArray components = config.getJsonArray(CONFIG_COMPONENTS, null); reader.accept(features); reader.accept(components); return set; } @Inject DefaultJerseyOptions(Vertx vertx); DefaultJerseyOptions(JsonObject config); @Override List<String> getPackages(); @Override Map<String, Object> getProperties(); @Override Set<Class<?>> getComponents(); @Override Set<Object> getInstances(); String getHost(); int getPort(); boolean getSSL(); JksOptions getKeyStoreOptions(); Integer getReceiveBufferSize(); int getAcceptBacklog(); @Override URI getBaseUri(); @Override int getMaxBodySize(); boolean getCompressionSupported(); @Override HttpServerOptions getServerOptions(); }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public Set<Class<?>> getComponents() { Set<Class<?>> set = new HashSet<>(); ClassLoader cl = Thread.currentThread().getContextClassLoader(); Consumer<JsonArray> reader = array -> { if (array != null && array.size() > 0) { for (int i = 0; i < array.size(); i++) { try { set.add(cl.loadClass(array.getString(i))); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } } } }; JsonArray features = config.getJsonArray(CONFIG_FEATURES, null); JsonArray components = config.getJsonArray(CONFIG_COMPONENTS, null); reader.accept(features); reader.accept(components); return set; } @Inject DefaultJerseyOptions(Vertx vertx); DefaultJerseyOptions(JsonObject config); @Override List<String> getPackages(); @Override Map<String, Object> getProperties(); @Override Set<Class<?>> getComponents(); @Override Set<Object> getInstances(); String getHost(); int getPort(); boolean getSSL(); JksOptions getKeyStoreOptions(); Integer getReceiveBufferSize(); int getAcceptBacklog(); @Override URI getBaseUri(); @Override int getMaxBodySize(); boolean getCompressionSupported(); @Override HttpServerOptions getServerOptions(); final static String CONFIG_HOST; final static String CONFIG_PORT; final static String CONFIG_SSL; final static String CONFIG_JKS_OPTIONS; final static String CONFIG_RECEIVE_BUFFER_SIZE; final static String CONFIG_BACKLOG_SIZE; final static String CONFIG_RESOURCE_CONFIG; final static String CONFIG_PROPERTIES; final static String CONFIG_COMPRESSION_SUPPORTED; static final String CONFIG_BASE_PATH; static final String CONFIG_MAX_BODY_SIZE; static final String CONFIG_RESOURCES; static final String CONFIG_PACKAGES; static final String CONFIG_FEATURES; static final String CONFIG_COMPONENTS; static final String CONFIG_BINDERS; static final String CONFIG_INSTANCES; static final int DEFAULT_MAX_BODY_SIZE; }
|
@Test public void testGetInstances() throws Exception { config.put(DefaultJerseyOptions.CONFIG_INSTANCES, new JsonArray().add(MyObj.class.getName())); config.put(DefaultJerseyOptions.CONFIG_BINDERS, new JsonArray().add(MyBinder.class.getName())); Set<Object> instances = options.getInstances(); assertNotNull(instances); assertEquals(2, instances.size()); List<Object> list = new ArrayList<>(instances); assertThat(list.get(0), instanceOf(MyObj.class)); assertThat(list.get(1), instanceOf(MyBinder.class)); }
|
@Override public Set<Object> getInstances() { Set<Object> set = new HashSet<>(); ClassLoader cl = Thread.currentThread().getContextClassLoader(); Consumer<JsonArray> reader = array -> { if (array != null && array.size() > 0) { for (int i = 0; i < array.size(); i++) { try { Class<?> clazz = cl.loadClass(array.getString(i)); set.add(clazz.newInstance()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { throw new RuntimeException(e); } } } }; JsonArray binders = config.getJsonArray(CONFIG_BINDERS, null); JsonArray instances = config.getJsonArray(CONFIG_INSTANCES, null); reader.accept(binders); reader.accept(instances); return set; }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public Set<Object> getInstances() { Set<Object> set = new HashSet<>(); ClassLoader cl = Thread.currentThread().getContextClassLoader(); Consumer<JsonArray> reader = array -> { if (array != null && array.size() > 0) { for (int i = 0; i < array.size(); i++) { try { Class<?> clazz = cl.loadClass(array.getString(i)); set.add(clazz.newInstance()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { throw new RuntimeException(e); } } } }; JsonArray binders = config.getJsonArray(CONFIG_BINDERS, null); JsonArray instances = config.getJsonArray(CONFIG_INSTANCES, null); reader.accept(binders); reader.accept(instances); return set; } }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public Set<Object> getInstances() { Set<Object> set = new HashSet<>(); ClassLoader cl = Thread.currentThread().getContextClassLoader(); Consumer<JsonArray> reader = array -> { if (array != null && array.size() > 0) { for (int i = 0; i < array.size(); i++) { try { Class<?> clazz = cl.loadClass(array.getString(i)); set.add(clazz.newInstance()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { throw new RuntimeException(e); } } } }; JsonArray binders = config.getJsonArray(CONFIG_BINDERS, null); JsonArray instances = config.getJsonArray(CONFIG_INSTANCES, null); reader.accept(binders); reader.accept(instances); return set; } @Inject DefaultJerseyOptions(Vertx vertx); DefaultJerseyOptions(JsonObject config); }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public Set<Object> getInstances() { Set<Object> set = new HashSet<>(); ClassLoader cl = Thread.currentThread().getContextClassLoader(); Consumer<JsonArray> reader = array -> { if (array != null && array.size() > 0) { for (int i = 0; i < array.size(); i++) { try { Class<?> clazz = cl.loadClass(array.getString(i)); set.add(clazz.newInstance()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { throw new RuntimeException(e); } } } }; JsonArray binders = config.getJsonArray(CONFIG_BINDERS, null); JsonArray instances = config.getJsonArray(CONFIG_INSTANCES, null); reader.accept(binders); reader.accept(instances); return set; } @Inject DefaultJerseyOptions(Vertx vertx); DefaultJerseyOptions(JsonObject config); @Override List<String> getPackages(); @Override Map<String, Object> getProperties(); @Override Set<Class<?>> getComponents(); @Override Set<Object> getInstances(); String getHost(); int getPort(); boolean getSSL(); JksOptions getKeyStoreOptions(); Integer getReceiveBufferSize(); int getAcceptBacklog(); @Override URI getBaseUri(); @Override int getMaxBodySize(); boolean getCompressionSupported(); @Override HttpServerOptions getServerOptions(); }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public Set<Object> getInstances() { Set<Object> set = new HashSet<>(); ClassLoader cl = Thread.currentThread().getContextClassLoader(); Consumer<JsonArray> reader = array -> { if (array != null && array.size() > 0) { for (int i = 0; i < array.size(); i++) { try { Class<?> clazz = cl.loadClass(array.getString(i)); set.add(clazz.newInstance()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { throw new RuntimeException(e); } } } }; JsonArray binders = config.getJsonArray(CONFIG_BINDERS, null); JsonArray instances = config.getJsonArray(CONFIG_INSTANCES, null); reader.accept(binders); reader.accept(instances); return set; } @Inject DefaultJerseyOptions(Vertx vertx); DefaultJerseyOptions(JsonObject config); @Override List<String> getPackages(); @Override Map<String, Object> getProperties(); @Override Set<Class<?>> getComponents(); @Override Set<Object> getInstances(); String getHost(); int getPort(); boolean getSSL(); JksOptions getKeyStoreOptions(); Integer getReceiveBufferSize(); int getAcceptBacklog(); @Override URI getBaseUri(); @Override int getMaxBodySize(); boolean getCompressionSupported(); @Override HttpServerOptions getServerOptions(); final static String CONFIG_HOST; final static String CONFIG_PORT; final static String CONFIG_SSL; final static String CONFIG_JKS_OPTIONS; final static String CONFIG_RECEIVE_BUFFER_SIZE; final static String CONFIG_BACKLOG_SIZE; final static String CONFIG_RESOURCE_CONFIG; final static String CONFIG_PROPERTIES; final static String CONFIG_COMPRESSION_SUPPORTED; static final String CONFIG_BASE_PATH; static final String CONFIG_MAX_BODY_SIZE; static final String CONFIG_RESOURCES; static final String CONFIG_PACKAGES; static final String CONFIG_FEATURES; static final String CONFIG_COMPONENTS; static final String CONFIG_BINDERS; static final String CONFIG_INSTANCES; static final int DEFAULT_MAX_BODY_SIZE; }
|
@Test(expected = RuntimeException.class) public void testGetInstances_Fail() throws Exception { config.put(DefaultJerseyOptions.CONFIG_INSTANCES, new JsonArray().add(MyObj.class.getName() + ".invalid")); options.getInstances(); fail(); }
|
@Override public Set<Object> getInstances() { Set<Object> set = new HashSet<>(); ClassLoader cl = Thread.currentThread().getContextClassLoader(); Consumer<JsonArray> reader = array -> { if (array != null && array.size() > 0) { for (int i = 0; i < array.size(); i++) { try { Class<?> clazz = cl.loadClass(array.getString(i)); set.add(clazz.newInstance()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { throw new RuntimeException(e); } } } }; JsonArray binders = config.getJsonArray(CONFIG_BINDERS, null); JsonArray instances = config.getJsonArray(CONFIG_INSTANCES, null); reader.accept(binders); reader.accept(instances); return set; }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public Set<Object> getInstances() { Set<Object> set = new HashSet<>(); ClassLoader cl = Thread.currentThread().getContextClassLoader(); Consumer<JsonArray> reader = array -> { if (array != null && array.size() > 0) { for (int i = 0; i < array.size(); i++) { try { Class<?> clazz = cl.loadClass(array.getString(i)); set.add(clazz.newInstance()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { throw new RuntimeException(e); } } } }; JsonArray binders = config.getJsonArray(CONFIG_BINDERS, null); JsonArray instances = config.getJsonArray(CONFIG_INSTANCES, null); reader.accept(binders); reader.accept(instances); return set; } }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public Set<Object> getInstances() { Set<Object> set = new HashSet<>(); ClassLoader cl = Thread.currentThread().getContextClassLoader(); Consumer<JsonArray> reader = array -> { if (array != null && array.size() > 0) { for (int i = 0; i < array.size(); i++) { try { Class<?> clazz = cl.loadClass(array.getString(i)); set.add(clazz.newInstance()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { throw new RuntimeException(e); } } } }; JsonArray binders = config.getJsonArray(CONFIG_BINDERS, null); JsonArray instances = config.getJsonArray(CONFIG_INSTANCES, null); reader.accept(binders); reader.accept(instances); return set; } @Inject DefaultJerseyOptions(Vertx vertx); DefaultJerseyOptions(JsonObject config); }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public Set<Object> getInstances() { Set<Object> set = new HashSet<>(); ClassLoader cl = Thread.currentThread().getContextClassLoader(); Consumer<JsonArray> reader = array -> { if (array != null && array.size() > 0) { for (int i = 0; i < array.size(); i++) { try { Class<?> clazz = cl.loadClass(array.getString(i)); set.add(clazz.newInstance()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { throw new RuntimeException(e); } } } }; JsonArray binders = config.getJsonArray(CONFIG_BINDERS, null); JsonArray instances = config.getJsonArray(CONFIG_INSTANCES, null); reader.accept(binders); reader.accept(instances); return set; } @Inject DefaultJerseyOptions(Vertx vertx); DefaultJerseyOptions(JsonObject config); @Override List<String> getPackages(); @Override Map<String, Object> getProperties(); @Override Set<Class<?>> getComponents(); @Override Set<Object> getInstances(); String getHost(); int getPort(); boolean getSSL(); JksOptions getKeyStoreOptions(); Integer getReceiveBufferSize(); int getAcceptBacklog(); @Override URI getBaseUri(); @Override int getMaxBodySize(); boolean getCompressionSupported(); @Override HttpServerOptions getServerOptions(); }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public Set<Object> getInstances() { Set<Object> set = new HashSet<>(); ClassLoader cl = Thread.currentThread().getContextClassLoader(); Consumer<JsonArray> reader = array -> { if (array != null && array.size() > 0) { for (int i = 0; i < array.size(); i++) { try { Class<?> clazz = cl.loadClass(array.getString(i)); set.add(clazz.newInstance()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { throw new RuntimeException(e); } } } }; JsonArray binders = config.getJsonArray(CONFIG_BINDERS, null); JsonArray instances = config.getJsonArray(CONFIG_INSTANCES, null); reader.accept(binders); reader.accept(instances); return set; } @Inject DefaultJerseyOptions(Vertx vertx); DefaultJerseyOptions(JsonObject config); @Override List<String> getPackages(); @Override Map<String, Object> getProperties(); @Override Set<Class<?>> getComponents(); @Override Set<Object> getInstances(); String getHost(); int getPort(); boolean getSSL(); JksOptions getKeyStoreOptions(); Integer getReceiveBufferSize(); int getAcceptBacklog(); @Override URI getBaseUri(); @Override int getMaxBodySize(); boolean getCompressionSupported(); @Override HttpServerOptions getServerOptions(); final static String CONFIG_HOST; final static String CONFIG_PORT; final static String CONFIG_SSL; final static String CONFIG_JKS_OPTIONS; final static String CONFIG_RECEIVE_BUFFER_SIZE; final static String CONFIG_BACKLOG_SIZE; final static String CONFIG_RESOURCE_CONFIG; final static String CONFIG_PROPERTIES; final static String CONFIG_COMPRESSION_SUPPORTED; static final String CONFIG_BASE_PATH; static final String CONFIG_MAX_BODY_SIZE; static final String CONFIG_RESOURCES; static final String CONFIG_PACKAGES; static final String CONFIG_FEATURES; static final String CONFIG_COMPONENTS; static final String CONFIG_BINDERS; static final String CONFIG_INSTANCES; static final int DEFAULT_MAX_BODY_SIZE; }
|
@Test public void testGetProperties() throws Exception { JsonObject props = new JsonObject().put("prop1", "a"); config.put(DefaultJerseyOptions.CONFIG_PROPERTIES, props); assertEquals(props.getMap(), options.getProperties()); }
|
@Override public Map<String, Object> getProperties() { JsonObject json = null; JsonObject tmp; tmp = config.getJsonObject(CONFIG_PROPERTIES); if (tmp != null) { json = tmp; } tmp = config.getJsonObject(CONFIG_RESOURCE_CONFIG); if (tmp != null) { if (json == null) { json = tmp; } else { json.mergeIn(tmp); } } return json == null ? null : json.getMap(); }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public Map<String, Object> getProperties() { JsonObject json = null; JsonObject tmp; tmp = config.getJsonObject(CONFIG_PROPERTIES); if (tmp != null) { json = tmp; } tmp = config.getJsonObject(CONFIG_RESOURCE_CONFIG); if (tmp != null) { if (json == null) { json = tmp; } else { json.mergeIn(tmp); } } return json == null ? null : json.getMap(); } }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public Map<String, Object> getProperties() { JsonObject json = null; JsonObject tmp; tmp = config.getJsonObject(CONFIG_PROPERTIES); if (tmp != null) { json = tmp; } tmp = config.getJsonObject(CONFIG_RESOURCE_CONFIG); if (tmp != null) { if (json == null) { json = tmp; } else { json.mergeIn(tmp); } } return json == null ? null : json.getMap(); } @Inject DefaultJerseyOptions(Vertx vertx); DefaultJerseyOptions(JsonObject config); }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public Map<String, Object> getProperties() { JsonObject json = null; JsonObject tmp; tmp = config.getJsonObject(CONFIG_PROPERTIES); if (tmp != null) { json = tmp; } tmp = config.getJsonObject(CONFIG_RESOURCE_CONFIG); if (tmp != null) { if (json == null) { json = tmp; } else { json.mergeIn(tmp); } } return json == null ? null : json.getMap(); } @Inject DefaultJerseyOptions(Vertx vertx); DefaultJerseyOptions(JsonObject config); @Override List<String> getPackages(); @Override Map<String, Object> getProperties(); @Override Set<Class<?>> getComponents(); @Override Set<Object> getInstances(); String getHost(); int getPort(); boolean getSSL(); JksOptions getKeyStoreOptions(); Integer getReceiveBufferSize(); int getAcceptBacklog(); @Override URI getBaseUri(); @Override int getMaxBodySize(); boolean getCompressionSupported(); @Override HttpServerOptions getServerOptions(); }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public Map<String, Object> getProperties() { JsonObject json = null; JsonObject tmp; tmp = config.getJsonObject(CONFIG_PROPERTIES); if (tmp != null) { json = tmp; } tmp = config.getJsonObject(CONFIG_RESOURCE_CONFIG); if (tmp != null) { if (json == null) { json = tmp; } else { json.mergeIn(tmp); } } return json == null ? null : json.getMap(); } @Inject DefaultJerseyOptions(Vertx vertx); DefaultJerseyOptions(JsonObject config); @Override List<String> getPackages(); @Override Map<String, Object> getProperties(); @Override Set<Class<?>> getComponents(); @Override Set<Object> getInstances(); String getHost(); int getPort(); boolean getSSL(); JksOptions getKeyStoreOptions(); Integer getReceiveBufferSize(); int getAcceptBacklog(); @Override URI getBaseUri(); @Override int getMaxBodySize(); boolean getCompressionSupported(); @Override HttpServerOptions getServerOptions(); final static String CONFIG_HOST; final static String CONFIG_PORT; final static String CONFIG_SSL; final static String CONFIG_JKS_OPTIONS; final static String CONFIG_RECEIVE_BUFFER_SIZE; final static String CONFIG_BACKLOG_SIZE; final static String CONFIG_RESOURCE_CONFIG; final static String CONFIG_PROPERTIES; final static String CONFIG_COMPRESSION_SUPPORTED; static final String CONFIG_BASE_PATH; static final String CONFIG_MAX_BODY_SIZE; static final String CONFIG_RESOURCES; static final String CONFIG_PACKAGES; static final String CONFIG_FEATURES; static final String CONFIG_COMPONENTS; static final String CONFIG_BINDERS; static final String CONFIG_INSTANCES; static final int DEFAULT_MAX_BODY_SIZE; }
|
@Test public void testGetProperties_Resource_Config() throws Exception { JsonObject rc = new JsonObject().put("prop1", "a"); config.put(DefaultJerseyOptions.CONFIG_RESOURCE_CONFIG, rc); assertEquals(rc.getMap(), options.getProperties()); }
|
@Override public Map<String, Object> getProperties() { JsonObject json = null; JsonObject tmp; tmp = config.getJsonObject(CONFIG_PROPERTIES); if (tmp != null) { json = tmp; } tmp = config.getJsonObject(CONFIG_RESOURCE_CONFIG); if (tmp != null) { if (json == null) { json = tmp; } else { json.mergeIn(tmp); } } return json == null ? null : json.getMap(); }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public Map<String, Object> getProperties() { JsonObject json = null; JsonObject tmp; tmp = config.getJsonObject(CONFIG_PROPERTIES); if (tmp != null) { json = tmp; } tmp = config.getJsonObject(CONFIG_RESOURCE_CONFIG); if (tmp != null) { if (json == null) { json = tmp; } else { json.mergeIn(tmp); } } return json == null ? null : json.getMap(); } }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public Map<String, Object> getProperties() { JsonObject json = null; JsonObject tmp; tmp = config.getJsonObject(CONFIG_PROPERTIES); if (tmp != null) { json = tmp; } tmp = config.getJsonObject(CONFIG_RESOURCE_CONFIG); if (tmp != null) { if (json == null) { json = tmp; } else { json.mergeIn(tmp); } } return json == null ? null : json.getMap(); } @Inject DefaultJerseyOptions(Vertx vertx); DefaultJerseyOptions(JsonObject config); }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public Map<String, Object> getProperties() { JsonObject json = null; JsonObject tmp; tmp = config.getJsonObject(CONFIG_PROPERTIES); if (tmp != null) { json = tmp; } tmp = config.getJsonObject(CONFIG_RESOURCE_CONFIG); if (tmp != null) { if (json == null) { json = tmp; } else { json.mergeIn(tmp); } } return json == null ? null : json.getMap(); } @Inject DefaultJerseyOptions(Vertx vertx); DefaultJerseyOptions(JsonObject config); @Override List<String> getPackages(); @Override Map<String, Object> getProperties(); @Override Set<Class<?>> getComponents(); @Override Set<Object> getInstances(); String getHost(); int getPort(); boolean getSSL(); JksOptions getKeyStoreOptions(); Integer getReceiveBufferSize(); int getAcceptBacklog(); @Override URI getBaseUri(); @Override int getMaxBodySize(); boolean getCompressionSupported(); @Override HttpServerOptions getServerOptions(); }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public Map<String, Object> getProperties() { JsonObject json = null; JsonObject tmp; tmp = config.getJsonObject(CONFIG_PROPERTIES); if (tmp != null) { json = tmp; } tmp = config.getJsonObject(CONFIG_RESOURCE_CONFIG); if (tmp != null) { if (json == null) { json = tmp; } else { json.mergeIn(tmp); } } return json == null ? null : json.getMap(); } @Inject DefaultJerseyOptions(Vertx vertx); DefaultJerseyOptions(JsonObject config); @Override List<String> getPackages(); @Override Map<String, Object> getProperties(); @Override Set<Class<?>> getComponents(); @Override Set<Object> getInstances(); String getHost(); int getPort(); boolean getSSL(); JksOptions getKeyStoreOptions(); Integer getReceiveBufferSize(); int getAcceptBacklog(); @Override URI getBaseUri(); @Override int getMaxBodySize(); boolean getCompressionSupported(); @Override HttpServerOptions getServerOptions(); final static String CONFIG_HOST; final static String CONFIG_PORT; final static String CONFIG_SSL; final static String CONFIG_JKS_OPTIONS; final static String CONFIG_RECEIVE_BUFFER_SIZE; final static String CONFIG_BACKLOG_SIZE; final static String CONFIG_RESOURCE_CONFIG; final static String CONFIG_PROPERTIES; final static String CONFIG_COMPRESSION_SUPPORTED; static final String CONFIG_BASE_PATH; static final String CONFIG_MAX_BODY_SIZE; static final String CONFIG_RESOURCES; static final String CONFIG_PACKAGES; static final String CONFIG_FEATURES; static final String CONFIG_COMPONENTS; static final String CONFIG_BINDERS; static final String CONFIG_INSTANCES; static final int DEFAULT_MAX_BODY_SIZE; }
|
@Test public void testGetProperties_Both() throws Exception { JsonObject props = new JsonObject().put("prop1", "a"); JsonObject rc = new JsonObject().put("prop2", "b"); config.put(DefaultJerseyOptions.CONFIG_PROPERTIES, props); config.put(DefaultJerseyOptions.CONFIG_RESOURCE_CONFIG, rc); Map<String, Object> map = options.getProperties(); assertEquals(2, map.size()); assertEquals("a", map.get("prop1")); assertEquals("b", map.get("prop2")); }
|
@Override public Map<String, Object> getProperties() { JsonObject json = null; JsonObject tmp; tmp = config.getJsonObject(CONFIG_PROPERTIES); if (tmp != null) { json = tmp; } tmp = config.getJsonObject(CONFIG_RESOURCE_CONFIG); if (tmp != null) { if (json == null) { json = tmp; } else { json.mergeIn(tmp); } } return json == null ? null : json.getMap(); }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public Map<String, Object> getProperties() { JsonObject json = null; JsonObject tmp; tmp = config.getJsonObject(CONFIG_PROPERTIES); if (tmp != null) { json = tmp; } tmp = config.getJsonObject(CONFIG_RESOURCE_CONFIG); if (tmp != null) { if (json == null) { json = tmp; } else { json.mergeIn(tmp); } } return json == null ? null : json.getMap(); } }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public Map<String, Object> getProperties() { JsonObject json = null; JsonObject tmp; tmp = config.getJsonObject(CONFIG_PROPERTIES); if (tmp != null) { json = tmp; } tmp = config.getJsonObject(CONFIG_RESOURCE_CONFIG); if (tmp != null) { if (json == null) { json = tmp; } else { json.mergeIn(tmp); } } return json == null ? null : json.getMap(); } @Inject DefaultJerseyOptions(Vertx vertx); DefaultJerseyOptions(JsonObject config); }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public Map<String, Object> getProperties() { JsonObject json = null; JsonObject tmp; tmp = config.getJsonObject(CONFIG_PROPERTIES); if (tmp != null) { json = tmp; } tmp = config.getJsonObject(CONFIG_RESOURCE_CONFIG); if (tmp != null) { if (json == null) { json = tmp; } else { json.mergeIn(tmp); } } return json == null ? null : json.getMap(); } @Inject DefaultJerseyOptions(Vertx vertx); DefaultJerseyOptions(JsonObject config); @Override List<String> getPackages(); @Override Map<String, Object> getProperties(); @Override Set<Class<?>> getComponents(); @Override Set<Object> getInstances(); String getHost(); int getPort(); boolean getSSL(); JksOptions getKeyStoreOptions(); Integer getReceiveBufferSize(); int getAcceptBacklog(); @Override URI getBaseUri(); @Override int getMaxBodySize(); boolean getCompressionSupported(); @Override HttpServerOptions getServerOptions(); }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public Map<String, Object> getProperties() { JsonObject json = null; JsonObject tmp; tmp = config.getJsonObject(CONFIG_PROPERTIES); if (tmp != null) { json = tmp; } tmp = config.getJsonObject(CONFIG_RESOURCE_CONFIG); if (tmp != null) { if (json == null) { json = tmp; } else { json.mergeIn(tmp); } } return json == null ? null : json.getMap(); } @Inject DefaultJerseyOptions(Vertx vertx); DefaultJerseyOptions(JsonObject config); @Override List<String> getPackages(); @Override Map<String, Object> getProperties(); @Override Set<Class<?>> getComponents(); @Override Set<Object> getInstances(); String getHost(); int getPort(); boolean getSSL(); JksOptions getKeyStoreOptions(); Integer getReceiveBufferSize(); int getAcceptBacklog(); @Override URI getBaseUri(); @Override int getMaxBodySize(); boolean getCompressionSupported(); @Override HttpServerOptions getServerOptions(); final static String CONFIG_HOST; final static String CONFIG_PORT; final static String CONFIG_SSL; final static String CONFIG_JKS_OPTIONS; final static String CONFIG_RECEIVE_BUFFER_SIZE; final static String CONFIG_BACKLOG_SIZE; final static String CONFIG_RESOURCE_CONFIG; final static String CONFIG_PROPERTIES; final static String CONFIG_COMPRESSION_SUPPORTED; static final String CONFIG_BASE_PATH; static final String CONFIG_MAX_BODY_SIZE; static final String CONFIG_RESOURCES; static final String CONFIG_PACKAGES; static final String CONFIG_FEATURES; static final String CONFIG_COMPONENTS; static final String CONFIG_BINDERS; static final String CONFIG_INSTANCES; static final int DEFAULT_MAX_BODY_SIZE; }
|
@Test public void testGetProperties_Null() throws Exception { JsonObject rc = new JsonObject().put("prop1", "a"); config.put(DefaultJerseyOptions.CONFIG_RESOURCE_CONFIG, rc); assertEquals(rc.getMap(), options.getProperties()); }
|
@Override public Map<String, Object> getProperties() { JsonObject json = null; JsonObject tmp; tmp = config.getJsonObject(CONFIG_PROPERTIES); if (tmp != null) { json = tmp; } tmp = config.getJsonObject(CONFIG_RESOURCE_CONFIG); if (tmp != null) { if (json == null) { json = tmp; } else { json.mergeIn(tmp); } } return json == null ? null : json.getMap(); }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public Map<String, Object> getProperties() { JsonObject json = null; JsonObject tmp; tmp = config.getJsonObject(CONFIG_PROPERTIES); if (tmp != null) { json = tmp; } tmp = config.getJsonObject(CONFIG_RESOURCE_CONFIG); if (tmp != null) { if (json == null) { json = tmp; } else { json.mergeIn(tmp); } } return json == null ? null : json.getMap(); } }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public Map<String, Object> getProperties() { JsonObject json = null; JsonObject tmp; tmp = config.getJsonObject(CONFIG_PROPERTIES); if (tmp != null) { json = tmp; } tmp = config.getJsonObject(CONFIG_RESOURCE_CONFIG); if (tmp != null) { if (json == null) { json = tmp; } else { json.mergeIn(tmp); } } return json == null ? null : json.getMap(); } @Inject DefaultJerseyOptions(Vertx vertx); DefaultJerseyOptions(JsonObject config); }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public Map<String, Object> getProperties() { JsonObject json = null; JsonObject tmp; tmp = config.getJsonObject(CONFIG_PROPERTIES); if (tmp != null) { json = tmp; } tmp = config.getJsonObject(CONFIG_RESOURCE_CONFIG); if (tmp != null) { if (json == null) { json = tmp; } else { json.mergeIn(tmp); } } return json == null ? null : json.getMap(); } @Inject DefaultJerseyOptions(Vertx vertx); DefaultJerseyOptions(JsonObject config); @Override List<String> getPackages(); @Override Map<String, Object> getProperties(); @Override Set<Class<?>> getComponents(); @Override Set<Object> getInstances(); String getHost(); int getPort(); boolean getSSL(); JksOptions getKeyStoreOptions(); Integer getReceiveBufferSize(); int getAcceptBacklog(); @Override URI getBaseUri(); @Override int getMaxBodySize(); boolean getCompressionSupported(); @Override HttpServerOptions getServerOptions(); }
|
DefaultJerseyOptions implements JerseyOptions, JerseyServerOptions { @Override public Map<String, Object> getProperties() { JsonObject json = null; JsonObject tmp; tmp = config.getJsonObject(CONFIG_PROPERTIES); if (tmp != null) { json = tmp; } tmp = config.getJsonObject(CONFIG_RESOURCE_CONFIG); if (tmp != null) { if (json == null) { json = tmp; } else { json.mergeIn(tmp); } } return json == null ? null : json.getMap(); } @Inject DefaultJerseyOptions(Vertx vertx); DefaultJerseyOptions(JsonObject config); @Override List<String> getPackages(); @Override Map<String, Object> getProperties(); @Override Set<Class<?>> getComponents(); @Override Set<Object> getInstances(); String getHost(); int getPort(); boolean getSSL(); JksOptions getKeyStoreOptions(); Integer getReceiveBufferSize(); int getAcceptBacklog(); @Override URI getBaseUri(); @Override int getMaxBodySize(); boolean getCompressionSupported(); @Override HttpServerOptions getServerOptions(); final static String CONFIG_HOST; final static String CONFIG_PORT; final static String CONFIG_SSL; final static String CONFIG_JKS_OPTIONS; final static String CONFIG_RECEIVE_BUFFER_SIZE; final static String CONFIG_BACKLOG_SIZE; final static String CONFIG_RESOURCE_CONFIG; final static String CONFIG_PROPERTIES; final static String CONFIG_COMPRESSION_SUPPORTED; static final String CONFIG_BASE_PATH; static final String CONFIG_MAX_BODY_SIZE; static final String CONFIG_RESOURCES; static final String CONFIG_PACKAGES; static final String CONFIG_FEATURES; static final String CONFIG_COMPONENTS; static final String CONFIG_BINDERS; static final String CONFIG_INSTANCES; static final int DEFAULT_MAX_BODY_SIZE; }
|
@Test public void testGet() throws Exception { ContainerResponseWriter writer; writer = provider.get(vertxRequest, jerseyRequest); assertNotNull(writer); }
|
@Override public ContainerResponseWriter get( HttpServerRequest vertxRequest, ContainerRequest jerseyRequest) { return new VertxResponseWriter(vertxRequest, vertx, responseProcessors, postResponseProcessors); }
|
VertxResponseWriterProvider implements ContainerResponseWriterProvider { @Override public ContainerResponseWriter get( HttpServerRequest vertxRequest, ContainerRequest jerseyRequest) { return new VertxResponseWriter(vertxRequest, vertx, responseProcessors, postResponseProcessors); } }
|
VertxResponseWriterProvider implements ContainerResponseWriterProvider { @Override public ContainerResponseWriter get( HttpServerRequest vertxRequest, ContainerRequest jerseyRequest) { return new VertxResponseWriter(vertxRequest, vertx, responseProcessors, postResponseProcessors); } @Inject VertxResponseWriterProvider(
Vertx vertx,
List<VertxResponseProcessor> responseProcessors,
List<VertxPostResponseProcessor> postResponseProcessors); }
|
VertxResponseWriterProvider implements ContainerResponseWriterProvider { @Override public ContainerResponseWriter get( HttpServerRequest vertxRequest, ContainerRequest jerseyRequest) { return new VertxResponseWriter(vertxRequest, vertx, responseProcessors, postResponseProcessors); } @Inject VertxResponseWriterProvider(
Vertx vertx,
List<VertxResponseProcessor> responseProcessors,
List<VertxPostResponseProcessor> postResponseProcessors); @Override ContainerResponseWriter get(
HttpServerRequest vertxRequest,
ContainerRequest jerseyRequest); }
|
VertxResponseWriterProvider implements ContainerResponseWriterProvider { @Override public ContainerResponseWriter get( HttpServerRequest vertxRequest, ContainerRequest jerseyRequest) { return new VertxResponseWriter(vertxRequest, vertx, responseProcessors, postResponseProcessors); } @Inject VertxResponseWriterProvider(
Vertx vertx,
List<VertxResponseProcessor> responseProcessors,
List<VertxPostResponseProcessor> postResponseProcessors); @Override ContainerResponseWriter get(
HttpServerRequest vertxRequest,
ContainerRequest jerseyRequest); }
|
@Test public void testInit_Default_Config() throws Exception { when(serverOptions.getHost()).thenReturn("0.0.0.0"); when(serverOptions.getPort()).thenReturn(80); jerseyServer.start(); verifyExecuteBlocking(); verifyResults(80, "0.0.0.0"); }
|
@Override public void start(@Nullable JerseyServerOptions options, @Nullable JerseyOptions jerseyOptions, @Nullable Handler<AsyncResult<HttpServer>> doneHandler) { if (options == null) { options = optionsProvider.get(); } HttpServerOptions serverOptions = options.getServerOptions(); if (serverOptions == null) { throw new IllegalArgumentException("http server options cannot be null"); } if (jerseyOptions != null) { container.setOptions(jerseyOptions); } jerseyHandler.setContainer(container); server = container.getVertx().createHttpServer(serverOptions); server.requestHandler(jerseyHandler::handle); if (setupHandler != null) { setupHandler.handle(server); } container.getVertx().executeBlocking( future -> { container.start(); future.complete(); }, result -> { if (result.failed()) { logger.error("Failed to start the jersey container", result.cause()); if (doneHandler != null) { doneHandler.handle(Future.failedFuture(result.cause())); } return; } server.listen(ar -> { final String listenPath = (serverOptions.isSsl() ? "https" : "http") + ": if (ar.succeeded()) { logger.info("Http server listening for " + listenPath); } else { logger.error("Failed to start http server listening for " + listenPath, ar.cause()); } if (doneHandler != null) { doneHandler.handle(ar); } }); }); }
|
DefaultJerseyServer implements JerseyServer { @Override public void start(@Nullable JerseyServerOptions options, @Nullable JerseyOptions jerseyOptions, @Nullable Handler<AsyncResult<HttpServer>> doneHandler) { if (options == null) { options = optionsProvider.get(); } HttpServerOptions serverOptions = options.getServerOptions(); if (serverOptions == null) { throw new IllegalArgumentException("http server options cannot be null"); } if (jerseyOptions != null) { container.setOptions(jerseyOptions); } jerseyHandler.setContainer(container); server = container.getVertx().createHttpServer(serverOptions); server.requestHandler(jerseyHandler::handle); if (setupHandler != null) { setupHandler.handle(server); } container.getVertx().executeBlocking( future -> { container.start(); future.complete(); }, result -> { if (result.failed()) { logger.error("Failed to start the jersey container", result.cause()); if (doneHandler != null) { doneHandler.handle(Future.failedFuture(result.cause())); } return; } server.listen(ar -> { final String listenPath = (serverOptions.isSsl() ? "https" : "http") + ": if (ar.succeeded()) { logger.info("Http server listening for " + listenPath); } else { logger.error("Failed to start http server listening for " + listenPath, ar.cause()); } if (doneHandler != null) { doneHandler.handle(ar); } }); }); } }
|
DefaultJerseyServer implements JerseyServer { @Override public void start(@Nullable JerseyServerOptions options, @Nullable JerseyOptions jerseyOptions, @Nullable Handler<AsyncResult<HttpServer>> doneHandler) { if (options == null) { options = optionsProvider.get(); } HttpServerOptions serverOptions = options.getServerOptions(); if (serverOptions == null) { throw new IllegalArgumentException("http server options cannot be null"); } if (jerseyOptions != null) { container.setOptions(jerseyOptions); } jerseyHandler.setContainer(container); server = container.getVertx().createHttpServer(serverOptions); server.requestHandler(jerseyHandler::handle); if (setupHandler != null) { setupHandler.handle(server); } container.getVertx().executeBlocking( future -> { container.start(); future.complete(); }, result -> { if (result.failed()) { logger.error("Failed to start the jersey container", result.cause()); if (doneHandler != null) { doneHandler.handle(Future.failedFuture(result.cause())); } return; } server.listen(ar -> { final String listenPath = (serverOptions.isSsl() ? "https" : "http") + ": if (ar.succeeded()) { logger.info("Http server listening for " + listenPath); } else { logger.error("Failed to start http server listening for " + listenPath, ar.cause()); } if (doneHandler != null) { doneHandler.handle(ar); } }); }); } @Inject DefaultJerseyServer(JerseyHandler jerseyHandler, VertxContainer container, Provider<JerseyServerOptions> optionsProvider); }
|
DefaultJerseyServer implements JerseyServer { @Override public void start(@Nullable JerseyServerOptions options, @Nullable JerseyOptions jerseyOptions, @Nullable Handler<AsyncResult<HttpServer>> doneHandler) { if (options == null) { options = optionsProvider.get(); } HttpServerOptions serverOptions = options.getServerOptions(); if (serverOptions == null) { throw new IllegalArgumentException("http server options cannot be null"); } if (jerseyOptions != null) { container.setOptions(jerseyOptions); } jerseyHandler.setContainer(container); server = container.getVertx().createHttpServer(serverOptions); server.requestHandler(jerseyHandler::handle); if (setupHandler != null) { setupHandler.handle(server); } container.getVertx().executeBlocking( future -> { container.start(); future.complete(); }, result -> { if (result.failed()) { logger.error("Failed to start the jersey container", result.cause()); if (doneHandler != null) { doneHandler.handle(Future.failedFuture(result.cause())); } return; } server.listen(ar -> { final String listenPath = (serverOptions.isSsl() ? "https" : "http") + ": if (ar.succeeded()) { logger.info("Http server listening for " + listenPath); } else { logger.error("Failed to start http server listening for " + listenPath, ar.cause()); } if (doneHandler != null) { doneHandler.handle(ar); } }); }); } @Inject DefaultJerseyServer(JerseyHandler jerseyHandler, VertxContainer container, Provider<JerseyServerOptions> optionsProvider); @Override void start(@Nullable JerseyServerOptions options, @Nullable JerseyOptions jerseyOptions, @Nullable Handler<AsyncResult<HttpServer>> doneHandler); @Override void setupHandler(Handler<HttpServer> handler); @Override JerseyHandler getHandler(); @Override HttpServer getHttpServer(); @Override void stop(); }
|
DefaultJerseyServer implements JerseyServer { @Override public void start(@Nullable JerseyServerOptions options, @Nullable JerseyOptions jerseyOptions, @Nullable Handler<AsyncResult<HttpServer>> doneHandler) { if (options == null) { options = optionsProvider.get(); } HttpServerOptions serverOptions = options.getServerOptions(); if (serverOptions == null) { throw new IllegalArgumentException("http server options cannot be null"); } if (jerseyOptions != null) { container.setOptions(jerseyOptions); } jerseyHandler.setContainer(container); server = container.getVertx().createHttpServer(serverOptions); server.requestHandler(jerseyHandler::handle); if (setupHandler != null) { setupHandler.handle(server); } container.getVertx().executeBlocking( future -> { container.start(); future.complete(); }, result -> { if (result.failed()) { logger.error("Failed to start the jersey container", result.cause()); if (doneHandler != null) { doneHandler.handle(Future.failedFuture(result.cause())); } return; } server.listen(ar -> { final String listenPath = (serverOptions.isSsl() ? "https" : "http") + ": if (ar.succeeded()) { logger.info("Http server listening for " + listenPath); } else { logger.error("Failed to start http server listening for " + listenPath, ar.cause()); } if (doneHandler != null) { doneHandler.handle(ar); } }); }); } @Inject DefaultJerseyServer(JerseyHandler jerseyHandler, VertxContainer container, Provider<JerseyServerOptions> optionsProvider); @Override void start(@Nullable JerseyServerOptions options, @Nullable JerseyOptions jerseyOptions, @Nullable Handler<AsyncResult<HttpServer>> doneHandler); @Override void setupHandler(Handler<HttpServer> handler); @Override JerseyHandler getHandler(); @Override HttpServer getHttpServer(); @Override void stop(); }
|
@Test public void testInit_With_Config() throws Exception { String host = "test.englishtown.com"; int port = 8888; int bufferSize = 1024; boolean ssl = true; boolean compressionSupported = true; when(serverOptions.getHost()).thenReturn(host); when(serverOptions.getPort()).thenReturn(port); when(serverOptions.getReceiveBufferSize()).thenReturn(bufferSize); when(serverOptions.isSsl()).thenReturn(ssl); when(serverOptions.isCompressionSupported()).thenReturn(compressionSupported); jerseyServer.start(); verifyExecuteBlocking(); verifyResults(port, host); verify(vertx).createHttpServer(optionsCaptor.capture()); HttpServerOptions options = optionsCaptor.getValue(); assertEquals(host, options.getHost()); assertEquals(port, options.getPort()); assertEquals(bufferSize, options.getReceiveBufferSize()); assertEquals(ssl, options.isSsl()); assertEquals(compressionSupported, options.isCompressionSupported()); }
|
@Override public void start(@Nullable JerseyServerOptions options, @Nullable JerseyOptions jerseyOptions, @Nullable Handler<AsyncResult<HttpServer>> doneHandler) { if (options == null) { options = optionsProvider.get(); } HttpServerOptions serverOptions = options.getServerOptions(); if (serverOptions == null) { throw new IllegalArgumentException("http server options cannot be null"); } if (jerseyOptions != null) { container.setOptions(jerseyOptions); } jerseyHandler.setContainer(container); server = container.getVertx().createHttpServer(serverOptions); server.requestHandler(jerseyHandler::handle); if (setupHandler != null) { setupHandler.handle(server); } container.getVertx().executeBlocking( future -> { container.start(); future.complete(); }, result -> { if (result.failed()) { logger.error("Failed to start the jersey container", result.cause()); if (doneHandler != null) { doneHandler.handle(Future.failedFuture(result.cause())); } return; } server.listen(ar -> { final String listenPath = (serverOptions.isSsl() ? "https" : "http") + ": if (ar.succeeded()) { logger.info("Http server listening for " + listenPath); } else { logger.error("Failed to start http server listening for " + listenPath, ar.cause()); } if (doneHandler != null) { doneHandler.handle(ar); } }); }); }
|
DefaultJerseyServer implements JerseyServer { @Override public void start(@Nullable JerseyServerOptions options, @Nullable JerseyOptions jerseyOptions, @Nullable Handler<AsyncResult<HttpServer>> doneHandler) { if (options == null) { options = optionsProvider.get(); } HttpServerOptions serverOptions = options.getServerOptions(); if (serverOptions == null) { throw new IllegalArgumentException("http server options cannot be null"); } if (jerseyOptions != null) { container.setOptions(jerseyOptions); } jerseyHandler.setContainer(container); server = container.getVertx().createHttpServer(serverOptions); server.requestHandler(jerseyHandler::handle); if (setupHandler != null) { setupHandler.handle(server); } container.getVertx().executeBlocking( future -> { container.start(); future.complete(); }, result -> { if (result.failed()) { logger.error("Failed to start the jersey container", result.cause()); if (doneHandler != null) { doneHandler.handle(Future.failedFuture(result.cause())); } return; } server.listen(ar -> { final String listenPath = (serverOptions.isSsl() ? "https" : "http") + ": if (ar.succeeded()) { logger.info("Http server listening for " + listenPath); } else { logger.error("Failed to start http server listening for " + listenPath, ar.cause()); } if (doneHandler != null) { doneHandler.handle(ar); } }); }); } }
|
DefaultJerseyServer implements JerseyServer { @Override public void start(@Nullable JerseyServerOptions options, @Nullable JerseyOptions jerseyOptions, @Nullable Handler<AsyncResult<HttpServer>> doneHandler) { if (options == null) { options = optionsProvider.get(); } HttpServerOptions serverOptions = options.getServerOptions(); if (serverOptions == null) { throw new IllegalArgumentException("http server options cannot be null"); } if (jerseyOptions != null) { container.setOptions(jerseyOptions); } jerseyHandler.setContainer(container); server = container.getVertx().createHttpServer(serverOptions); server.requestHandler(jerseyHandler::handle); if (setupHandler != null) { setupHandler.handle(server); } container.getVertx().executeBlocking( future -> { container.start(); future.complete(); }, result -> { if (result.failed()) { logger.error("Failed to start the jersey container", result.cause()); if (doneHandler != null) { doneHandler.handle(Future.failedFuture(result.cause())); } return; } server.listen(ar -> { final String listenPath = (serverOptions.isSsl() ? "https" : "http") + ": if (ar.succeeded()) { logger.info("Http server listening for " + listenPath); } else { logger.error("Failed to start http server listening for " + listenPath, ar.cause()); } if (doneHandler != null) { doneHandler.handle(ar); } }); }); } @Inject DefaultJerseyServer(JerseyHandler jerseyHandler, VertxContainer container, Provider<JerseyServerOptions> optionsProvider); }
|
DefaultJerseyServer implements JerseyServer { @Override public void start(@Nullable JerseyServerOptions options, @Nullable JerseyOptions jerseyOptions, @Nullable Handler<AsyncResult<HttpServer>> doneHandler) { if (options == null) { options = optionsProvider.get(); } HttpServerOptions serverOptions = options.getServerOptions(); if (serverOptions == null) { throw new IllegalArgumentException("http server options cannot be null"); } if (jerseyOptions != null) { container.setOptions(jerseyOptions); } jerseyHandler.setContainer(container); server = container.getVertx().createHttpServer(serverOptions); server.requestHandler(jerseyHandler::handle); if (setupHandler != null) { setupHandler.handle(server); } container.getVertx().executeBlocking( future -> { container.start(); future.complete(); }, result -> { if (result.failed()) { logger.error("Failed to start the jersey container", result.cause()); if (doneHandler != null) { doneHandler.handle(Future.failedFuture(result.cause())); } return; } server.listen(ar -> { final String listenPath = (serverOptions.isSsl() ? "https" : "http") + ": if (ar.succeeded()) { logger.info("Http server listening for " + listenPath); } else { logger.error("Failed to start http server listening for " + listenPath, ar.cause()); } if (doneHandler != null) { doneHandler.handle(ar); } }); }); } @Inject DefaultJerseyServer(JerseyHandler jerseyHandler, VertxContainer container, Provider<JerseyServerOptions> optionsProvider); @Override void start(@Nullable JerseyServerOptions options, @Nullable JerseyOptions jerseyOptions, @Nullable Handler<AsyncResult<HttpServer>> doneHandler); @Override void setupHandler(Handler<HttpServer> handler); @Override JerseyHandler getHandler(); @Override HttpServer getHttpServer(); @Override void stop(); }
|
DefaultJerseyServer implements JerseyServer { @Override public void start(@Nullable JerseyServerOptions options, @Nullable JerseyOptions jerseyOptions, @Nullable Handler<AsyncResult<HttpServer>> doneHandler) { if (options == null) { options = optionsProvider.get(); } HttpServerOptions serverOptions = options.getServerOptions(); if (serverOptions == null) { throw new IllegalArgumentException("http server options cannot be null"); } if (jerseyOptions != null) { container.setOptions(jerseyOptions); } jerseyHandler.setContainer(container); server = container.getVertx().createHttpServer(serverOptions); server.requestHandler(jerseyHandler::handle); if (setupHandler != null) { setupHandler.handle(server); } container.getVertx().executeBlocking( future -> { container.start(); future.complete(); }, result -> { if (result.failed()) { logger.error("Failed to start the jersey container", result.cause()); if (doneHandler != null) { doneHandler.handle(Future.failedFuture(result.cause())); } return; } server.listen(ar -> { final String listenPath = (serverOptions.isSsl() ? "https" : "http") + ": if (ar.succeeded()) { logger.info("Http server listening for " + listenPath); } else { logger.error("Failed to start http server listening for " + listenPath, ar.cause()); } if (doneHandler != null) { doneHandler.handle(ar); } }); }); } @Inject DefaultJerseyServer(JerseyHandler jerseyHandler, VertxContainer container, Provider<JerseyServerOptions> optionsProvider); @Override void start(@Nullable JerseyServerOptions options, @Nullable JerseyOptions jerseyOptions, @Nullable Handler<AsyncResult<HttpServer>> doneHandler); @Override void setupHandler(Handler<HttpServer> handler); @Override JerseyHandler getHandler(); @Override HttpServer getHttpServer(); @Override void stop(); }
|
@Test public void testInit_Listen_Result() throws Exception { jerseyServer.start(doneHandler); verifyExecuteBlocking(); verify(httpServer).listen(handlerCaptor.capture()); Handler<AsyncResult<HttpServer>> handler = handlerCaptor.getValue(); when(asyncResult.succeeded()).thenReturn(true).thenReturn(false); handler.handle(asyncResult); handler.handle(asyncResult); verify(doneHandler, times(2)).handle(eq(asyncResult)); }
|
@Override public void start(@Nullable JerseyServerOptions options, @Nullable JerseyOptions jerseyOptions, @Nullable Handler<AsyncResult<HttpServer>> doneHandler) { if (options == null) { options = optionsProvider.get(); } HttpServerOptions serverOptions = options.getServerOptions(); if (serverOptions == null) { throw new IllegalArgumentException("http server options cannot be null"); } if (jerseyOptions != null) { container.setOptions(jerseyOptions); } jerseyHandler.setContainer(container); server = container.getVertx().createHttpServer(serverOptions); server.requestHandler(jerseyHandler::handle); if (setupHandler != null) { setupHandler.handle(server); } container.getVertx().executeBlocking( future -> { container.start(); future.complete(); }, result -> { if (result.failed()) { logger.error("Failed to start the jersey container", result.cause()); if (doneHandler != null) { doneHandler.handle(Future.failedFuture(result.cause())); } return; } server.listen(ar -> { final String listenPath = (serverOptions.isSsl() ? "https" : "http") + ": if (ar.succeeded()) { logger.info("Http server listening for " + listenPath); } else { logger.error("Failed to start http server listening for " + listenPath, ar.cause()); } if (doneHandler != null) { doneHandler.handle(ar); } }); }); }
|
DefaultJerseyServer implements JerseyServer { @Override public void start(@Nullable JerseyServerOptions options, @Nullable JerseyOptions jerseyOptions, @Nullable Handler<AsyncResult<HttpServer>> doneHandler) { if (options == null) { options = optionsProvider.get(); } HttpServerOptions serverOptions = options.getServerOptions(); if (serverOptions == null) { throw new IllegalArgumentException("http server options cannot be null"); } if (jerseyOptions != null) { container.setOptions(jerseyOptions); } jerseyHandler.setContainer(container); server = container.getVertx().createHttpServer(serverOptions); server.requestHandler(jerseyHandler::handle); if (setupHandler != null) { setupHandler.handle(server); } container.getVertx().executeBlocking( future -> { container.start(); future.complete(); }, result -> { if (result.failed()) { logger.error("Failed to start the jersey container", result.cause()); if (doneHandler != null) { doneHandler.handle(Future.failedFuture(result.cause())); } return; } server.listen(ar -> { final String listenPath = (serverOptions.isSsl() ? "https" : "http") + ": if (ar.succeeded()) { logger.info("Http server listening for " + listenPath); } else { logger.error("Failed to start http server listening for " + listenPath, ar.cause()); } if (doneHandler != null) { doneHandler.handle(ar); } }); }); } }
|
DefaultJerseyServer implements JerseyServer { @Override public void start(@Nullable JerseyServerOptions options, @Nullable JerseyOptions jerseyOptions, @Nullable Handler<AsyncResult<HttpServer>> doneHandler) { if (options == null) { options = optionsProvider.get(); } HttpServerOptions serverOptions = options.getServerOptions(); if (serverOptions == null) { throw new IllegalArgumentException("http server options cannot be null"); } if (jerseyOptions != null) { container.setOptions(jerseyOptions); } jerseyHandler.setContainer(container); server = container.getVertx().createHttpServer(serverOptions); server.requestHandler(jerseyHandler::handle); if (setupHandler != null) { setupHandler.handle(server); } container.getVertx().executeBlocking( future -> { container.start(); future.complete(); }, result -> { if (result.failed()) { logger.error("Failed to start the jersey container", result.cause()); if (doneHandler != null) { doneHandler.handle(Future.failedFuture(result.cause())); } return; } server.listen(ar -> { final String listenPath = (serverOptions.isSsl() ? "https" : "http") + ": if (ar.succeeded()) { logger.info("Http server listening for " + listenPath); } else { logger.error("Failed to start http server listening for " + listenPath, ar.cause()); } if (doneHandler != null) { doneHandler.handle(ar); } }); }); } @Inject DefaultJerseyServer(JerseyHandler jerseyHandler, VertxContainer container, Provider<JerseyServerOptions> optionsProvider); }
|
DefaultJerseyServer implements JerseyServer { @Override public void start(@Nullable JerseyServerOptions options, @Nullable JerseyOptions jerseyOptions, @Nullable Handler<AsyncResult<HttpServer>> doneHandler) { if (options == null) { options = optionsProvider.get(); } HttpServerOptions serverOptions = options.getServerOptions(); if (serverOptions == null) { throw new IllegalArgumentException("http server options cannot be null"); } if (jerseyOptions != null) { container.setOptions(jerseyOptions); } jerseyHandler.setContainer(container); server = container.getVertx().createHttpServer(serverOptions); server.requestHandler(jerseyHandler::handle); if (setupHandler != null) { setupHandler.handle(server); } container.getVertx().executeBlocking( future -> { container.start(); future.complete(); }, result -> { if (result.failed()) { logger.error("Failed to start the jersey container", result.cause()); if (doneHandler != null) { doneHandler.handle(Future.failedFuture(result.cause())); } return; } server.listen(ar -> { final String listenPath = (serverOptions.isSsl() ? "https" : "http") + ": if (ar.succeeded()) { logger.info("Http server listening for " + listenPath); } else { logger.error("Failed to start http server listening for " + listenPath, ar.cause()); } if (doneHandler != null) { doneHandler.handle(ar); } }); }); } @Inject DefaultJerseyServer(JerseyHandler jerseyHandler, VertxContainer container, Provider<JerseyServerOptions> optionsProvider); @Override void start(@Nullable JerseyServerOptions options, @Nullable JerseyOptions jerseyOptions, @Nullable Handler<AsyncResult<HttpServer>> doneHandler); @Override void setupHandler(Handler<HttpServer> handler); @Override JerseyHandler getHandler(); @Override HttpServer getHttpServer(); @Override void stop(); }
|
DefaultJerseyServer implements JerseyServer { @Override public void start(@Nullable JerseyServerOptions options, @Nullable JerseyOptions jerseyOptions, @Nullable Handler<AsyncResult<HttpServer>> doneHandler) { if (options == null) { options = optionsProvider.get(); } HttpServerOptions serverOptions = options.getServerOptions(); if (serverOptions == null) { throw new IllegalArgumentException("http server options cannot be null"); } if (jerseyOptions != null) { container.setOptions(jerseyOptions); } jerseyHandler.setContainer(container); server = container.getVertx().createHttpServer(serverOptions); server.requestHandler(jerseyHandler::handle); if (setupHandler != null) { setupHandler.handle(server); } container.getVertx().executeBlocking( future -> { container.start(); future.complete(); }, result -> { if (result.failed()) { logger.error("Failed to start the jersey container", result.cause()); if (doneHandler != null) { doneHandler.handle(Future.failedFuture(result.cause())); } return; } server.listen(ar -> { final String listenPath = (serverOptions.isSsl() ? "https" : "http") + ": if (ar.succeeded()) { logger.info("Http server listening for " + listenPath); } else { logger.error("Failed to start http server listening for " + listenPath, ar.cause()); } if (doneHandler != null) { doneHandler.handle(ar); } }); }); } @Inject DefaultJerseyServer(JerseyHandler jerseyHandler, VertxContainer container, Provider<JerseyServerOptions> optionsProvider); @Override void start(@Nullable JerseyServerOptions options, @Nullable JerseyOptions jerseyOptions, @Nullable Handler<AsyncResult<HttpServer>> doneHandler); @Override void setupHandler(Handler<HttpServer> handler); @Override JerseyHandler getHandler(); @Override HttpServer getHttpServer(); @Override void stop(); }
|
@Test public void testGetHandler() throws Exception { jerseyServer.start(); JerseyHandler handler = jerseyServer.getHandler(); assertEquals(jerseyHandler, handler); }
|
@Override public JerseyHandler getHandler() { return jerseyHandler; }
|
DefaultJerseyServer implements JerseyServer { @Override public JerseyHandler getHandler() { return jerseyHandler; } }
|
DefaultJerseyServer implements JerseyServer { @Override public JerseyHandler getHandler() { return jerseyHandler; } @Inject DefaultJerseyServer(JerseyHandler jerseyHandler, VertxContainer container, Provider<JerseyServerOptions> optionsProvider); }
|
DefaultJerseyServer implements JerseyServer { @Override public JerseyHandler getHandler() { return jerseyHandler; } @Inject DefaultJerseyServer(JerseyHandler jerseyHandler, VertxContainer container, Provider<JerseyServerOptions> optionsProvider); @Override void start(@Nullable JerseyServerOptions options, @Nullable JerseyOptions jerseyOptions, @Nullable Handler<AsyncResult<HttpServer>> doneHandler); @Override void setupHandler(Handler<HttpServer> handler); @Override JerseyHandler getHandler(); @Override HttpServer getHttpServer(); @Override void stop(); }
|
DefaultJerseyServer implements JerseyServer { @Override public JerseyHandler getHandler() { return jerseyHandler; } @Inject DefaultJerseyServer(JerseyHandler jerseyHandler, VertxContainer container, Provider<JerseyServerOptions> optionsProvider); @Override void start(@Nullable JerseyServerOptions options, @Nullable JerseyOptions jerseyOptions, @Nullable Handler<AsyncResult<HttpServer>> doneHandler); @Override void setupHandler(Handler<HttpServer> handler); @Override JerseyHandler getHandler(); @Override HttpServer getHttpServer(); @Override void stop(); }
|
@Test public void testSetupHandler() throws Exception { jerseyServer.setupHandler(setupHandler); jerseyServer.start(); verify(setupHandler).handle(eq(httpServer)); Handler<HttpServerRequest> requestHandler = jerseyServer.getHandler(); assertNotNull(requestHandler); httpServer.requestHandler(request -> { }); }
|
@Override public void setupHandler(Handler<HttpServer> handler) { this.setupHandler = handler; }
|
DefaultJerseyServer implements JerseyServer { @Override public void setupHandler(Handler<HttpServer> handler) { this.setupHandler = handler; } }
|
DefaultJerseyServer implements JerseyServer { @Override public void setupHandler(Handler<HttpServer> handler) { this.setupHandler = handler; } @Inject DefaultJerseyServer(JerseyHandler jerseyHandler, VertxContainer container, Provider<JerseyServerOptions> optionsProvider); }
|
DefaultJerseyServer implements JerseyServer { @Override public void setupHandler(Handler<HttpServer> handler) { this.setupHandler = handler; } @Inject DefaultJerseyServer(JerseyHandler jerseyHandler, VertxContainer container, Provider<JerseyServerOptions> optionsProvider); @Override void start(@Nullable JerseyServerOptions options, @Nullable JerseyOptions jerseyOptions, @Nullable Handler<AsyncResult<HttpServer>> doneHandler); @Override void setupHandler(Handler<HttpServer> handler); @Override JerseyHandler getHandler(); @Override HttpServer getHttpServer(); @Override void stop(); }
|
DefaultJerseyServer implements JerseyServer { @Override public void setupHandler(Handler<HttpServer> handler) { this.setupHandler = handler; } @Inject DefaultJerseyServer(JerseyHandler jerseyHandler, VertxContainer container, Provider<JerseyServerOptions> optionsProvider); @Override void start(@Nullable JerseyServerOptions options, @Nullable JerseyOptions jerseyOptions, @Nullable Handler<AsyncResult<HttpServer>> doneHandler); @Override void setupHandler(Handler<HttpServer> handler); @Override JerseyHandler getHandler(); @Override HttpServer getHttpServer(); @Override void stop(); }
|
@Test public void testGetHttpServer() throws Exception { jerseyServer.start(); HttpServer server = jerseyServer.getHttpServer(); assertEquals(httpServer, server); }
|
@Override public HttpServer getHttpServer() { return server; }
|
DefaultJerseyServer implements JerseyServer { @Override public HttpServer getHttpServer() { return server; } }
|
DefaultJerseyServer implements JerseyServer { @Override public HttpServer getHttpServer() { return server; } @Inject DefaultJerseyServer(JerseyHandler jerseyHandler, VertxContainer container, Provider<JerseyServerOptions> optionsProvider); }
|
DefaultJerseyServer implements JerseyServer { @Override public HttpServer getHttpServer() { return server; } @Inject DefaultJerseyServer(JerseyHandler jerseyHandler, VertxContainer container, Provider<JerseyServerOptions> optionsProvider); @Override void start(@Nullable JerseyServerOptions options, @Nullable JerseyOptions jerseyOptions, @Nullable Handler<AsyncResult<HttpServer>> doneHandler); @Override void setupHandler(Handler<HttpServer> handler); @Override JerseyHandler getHandler(); @Override HttpServer getHttpServer(); @Override void stop(); }
|
DefaultJerseyServer implements JerseyServer { @Override public HttpServer getHttpServer() { return server; } @Inject DefaultJerseyServer(JerseyHandler jerseyHandler, VertxContainer container, Provider<JerseyServerOptions> optionsProvider); @Override void start(@Nullable JerseyServerOptions options, @Nullable JerseyOptions jerseyOptions, @Nullable Handler<AsyncResult<HttpServer>> doneHandler); @Override void setupHandler(Handler<HttpServer> handler); @Override JerseyHandler getHandler(); @Override HttpServer getHttpServer(); @Override void stop(); }
|
@Test public void testHandle() throws Exception { when(request.method()).thenReturn(HttpMethod.GET); when(request.headers()).thenReturn(mock(MultiMap.class)); jerseyHandler.handle(request); verify(applicationHandlerDelegate).handle(any(ContainerRequest.class)); }
|
@Override public void handle(final HttpServerRequest vertxRequest) { if (shouldReadData(vertxRequest)) { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request and read body: " + vertxRequest.method() + " " + vertxRequest.uri()); } final Buffer body = Buffer.buffer(); vertxRequest.handler(buffer -> { body.appendBuffer(buffer); if (body.length() > getMaxBodySize()) { throw new RuntimeException("The input stream has exceeded the max allowed body size " + getMaxBodySize() + "."); } }); vertxRequest.endHandler(aVoid -> { InputStream inputStream = new ByteArrayInputStream(body.getBytes()); DefaultJerseyHandler.this.handle(vertxRequest, inputStream); }); } else { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request: " + vertxRequest.method() + " " + vertxRequest.uri()); } DefaultJerseyHandler.this.handle(vertxRequest, null); } }
|
DefaultJerseyHandler implements JerseyHandler { @Override public void handle(final HttpServerRequest vertxRequest) { if (shouldReadData(vertxRequest)) { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request and read body: " + vertxRequest.method() + " " + vertxRequest.uri()); } final Buffer body = Buffer.buffer(); vertxRequest.handler(buffer -> { body.appendBuffer(buffer); if (body.length() > getMaxBodySize()) { throw new RuntimeException("The input stream has exceeded the max allowed body size " + getMaxBodySize() + "."); } }); vertxRequest.endHandler(aVoid -> { InputStream inputStream = new ByteArrayInputStream(body.getBytes()); DefaultJerseyHandler.this.handle(vertxRequest, inputStream); }); } else { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request: " + vertxRequest.method() + " " + vertxRequest.uri()); } DefaultJerseyHandler.this.handle(vertxRequest, null); } } }
|
DefaultJerseyHandler implements JerseyHandler { @Override public void handle(final HttpServerRequest vertxRequest) { if (shouldReadData(vertxRequest)) { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request and read body: " + vertxRequest.method() + " " + vertxRequest.uri()); } final Buffer body = Buffer.buffer(); vertxRequest.handler(buffer -> { body.appendBuffer(buffer); if (body.length() > getMaxBodySize()) { throw new RuntimeException("The input stream has exceeded the max allowed body size " + getMaxBodySize() + "."); } }); vertxRequest.endHandler(aVoid -> { InputStream inputStream = new ByteArrayInputStream(body.getBytes()); DefaultJerseyHandler.this.handle(vertxRequest, inputStream); }); } else { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request: " + vertxRequest.method() + " " + vertxRequest.uri()); } DefaultJerseyHandler.this.handle(vertxRequest, null); } } @Inject DefaultJerseyHandler(
Provider<VertxContainer> containerProvider,
ContainerResponseWriterProvider responseWriterProvider,
List<VertxRequestProcessor> requestProcessors); }
|
DefaultJerseyHandler implements JerseyHandler { @Override public void handle(final HttpServerRequest vertxRequest) { if (shouldReadData(vertxRequest)) { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request and read body: " + vertxRequest.method() + " " + vertxRequest.uri()); } final Buffer body = Buffer.buffer(); vertxRequest.handler(buffer -> { body.appendBuffer(buffer); if (body.length() > getMaxBodySize()) { throw new RuntimeException("The input stream has exceeded the max allowed body size " + getMaxBodySize() + "."); } }); vertxRequest.endHandler(aVoid -> { InputStream inputStream = new ByteArrayInputStream(body.getBytes()); DefaultJerseyHandler.this.handle(vertxRequest, inputStream); }); } else { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request: " + vertxRequest.method() + " " + vertxRequest.uri()); } DefaultJerseyHandler.this.handle(vertxRequest, null); } } @Inject DefaultJerseyHandler(
Provider<VertxContainer> containerProvider,
ContainerResponseWriterProvider responseWriterProvider,
List<VertxRequestProcessor> requestProcessors); @Override URI getBaseUri(); int getMaxBodySize(); @Override ApplicationHandlerDelegate getDelegate(); @Override VertxContainer getContainer(); @Override JerseyHandler setContainer(VertxContainer container); @Override void handle(final HttpServerRequest vertxRequest); }
|
DefaultJerseyHandler implements JerseyHandler { @Override public void handle(final HttpServerRequest vertxRequest) { if (shouldReadData(vertxRequest)) { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request and read body: " + vertxRequest.method() + " " + vertxRequest.uri()); } final Buffer body = Buffer.buffer(); vertxRequest.handler(buffer -> { body.appendBuffer(buffer); if (body.length() > getMaxBodySize()) { throw new RuntimeException("The input stream has exceeded the max allowed body size " + getMaxBodySize() + "."); } }); vertxRequest.endHandler(aVoid -> { InputStream inputStream = new ByteArrayInputStream(body.getBytes()); DefaultJerseyHandler.this.handle(vertxRequest, inputStream); }); } else { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request: " + vertxRequest.method() + " " + vertxRequest.uri()); } DefaultJerseyHandler.this.handle(vertxRequest, null); } } @Inject DefaultJerseyHandler(
Provider<VertxContainer> containerProvider,
ContainerResponseWriterProvider responseWriterProvider,
List<VertxRequestProcessor> requestProcessors); @Override URI getBaseUri(); int getMaxBodySize(); @Override ApplicationHandlerDelegate getDelegate(); @Override VertxContainer getContainer(); @Override JerseyHandler setContainer(VertxContainer container); @Override void handle(final HttpServerRequest vertxRequest); }
|
@Test public void testHandle_JSON_POST() throws Exception { DefaultHttpHeaders headers = new DefaultHttpHeaders(); headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON); when(request.method()).thenReturn(HttpMethod.POST); when(request.headers()).thenReturn(new HeadersAdaptor(headers)); jerseyHandler.handle(request); verify(request).handler(dataHandlerCaptor.capture()); verify(request).endHandler(endHandlerCaptor.capture()); Buffer data = Buffer.buffer("{}"); dataHandlerCaptor.getValue().handle(data); endHandlerCaptor.getValue().handle(null); verify(applicationHandlerDelegate).handle(any(ContainerRequest.class)); }
|
@Override public void handle(final HttpServerRequest vertxRequest) { if (shouldReadData(vertxRequest)) { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request and read body: " + vertxRequest.method() + " " + vertxRequest.uri()); } final Buffer body = Buffer.buffer(); vertxRequest.handler(buffer -> { body.appendBuffer(buffer); if (body.length() > getMaxBodySize()) { throw new RuntimeException("The input stream has exceeded the max allowed body size " + getMaxBodySize() + "."); } }); vertxRequest.endHandler(aVoid -> { InputStream inputStream = new ByteArrayInputStream(body.getBytes()); DefaultJerseyHandler.this.handle(vertxRequest, inputStream); }); } else { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request: " + vertxRequest.method() + " " + vertxRequest.uri()); } DefaultJerseyHandler.this.handle(vertxRequest, null); } }
|
DefaultJerseyHandler implements JerseyHandler { @Override public void handle(final HttpServerRequest vertxRequest) { if (shouldReadData(vertxRequest)) { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request and read body: " + vertxRequest.method() + " " + vertxRequest.uri()); } final Buffer body = Buffer.buffer(); vertxRequest.handler(buffer -> { body.appendBuffer(buffer); if (body.length() > getMaxBodySize()) { throw new RuntimeException("The input stream has exceeded the max allowed body size " + getMaxBodySize() + "."); } }); vertxRequest.endHandler(aVoid -> { InputStream inputStream = new ByteArrayInputStream(body.getBytes()); DefaultJerseyHandler.this.handle(vertxRequest, inputStream); }); } else { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request: " + vertxRequest.method() + " " + vertxRequest.uri()); } DefaultJerseyHandler.this.handle(vertxRequest, null); } } }
|
DefaultJerseyHandler implements JerseyHandler { @Override public void handle(final HttpServerRequest vertxRequest) { if (shouldReadData(vertxRequest)) { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request and read body: " + vertxRequest.method() + " " + vertxRequest.uri()); } final Buffer body = Buffer.buffer(); vertxRequest.handler(buffer -> { body.appendBuffer(buffer); if (body.length() > getMaxBodySize()) { throw new RuntimeException("The input stream has exceeded the max allowed body size " + getMaxBodySize() + "."); } }); vertxRequest.endHandler(aVoid -> { InputStream inputStream = new ByteArrayInputStream(body.getBytes()); DefaultJerseyHandler.this.handle(vertxRequest, inputStream); }); } else { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request: " + vertxRequest.method() + " " + vertxRequest.uri()); } DefaultJerseyHandler.this.handle(vertxRequest, null); } } @Inject DefaultJerseyHandler(
Provider<VertxContainer> containerProvider,
ContainerResponseWriterProvider responseWriterProvider,
List<VertxRequestProcessor> requestProcessors); }
|
DefaultJerseyHandler implements JerseyHandler { @Override public void handle(final HttpServerRequest vertxRequest) { if (shouldReadData(vertxRequest)) { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request and read body: " + vertxRequest.method() + " " + vertxRequest.uri()); } final Buffer body = Buffer.buffer(); vertxRequest.handler(buffer -> { body.appendBuffer(buffer); if (body.length() > getMaxBodySize()) { throw new RuntimeException("The input stream has exceeded the max allowed body size " + getMaxBodySize() + "."); } }); vertxRequest.endHandler(aVoid -> { InputStream inputStream = new ByteArrayInputStream(body.getBytes()); DefaultJerseyHandler.this.handle(vertxRequest, inputStream); }); } else { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request: " + vertxRequest.method() + " " + vertxRequest.uri()); } DefaultJerseyHandler.this.handle(vertxRequest, null); } } @Inject DefaultJerseyHandler(
Provider<VertxContainer> containerProvider,
ContainerResponseWriterProvider responseWriterProvider,
List<VertxRequestProcessor> requestProcessors); @Override URI getBaseUri(); int getMaxBodySize(); @Override ApplicationHandlerDelegate getDelegate(); @Override VertxContainer getContainer(); @Override JerseyHandler setContainer(VertxContainer container); @Override void handle(final HttpServerRequest vertxRequest); }
|
DefaultJerseyHandler implements JerseyHandler { @Override public void handle(final HttpServerRequest vertxRequest) { if (shouldReadData(vertxRequest)) { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request and read body: " + vertxRequest.method() + " " + vertxRequest.uri()); } final Buffer body = Buffer.buffer(); vertxRequest.handler(buffer -> { body.appendBuffer(buffer); if (body.length() > getMaxBodySize()) { throw new RuntimeException("The input stream has exceeded the max allowed body size " + getMaxBodySize() + "."); } }); vertxRequest.endHandler(aVoid -> { InputStream inputStream = new ByteArrayInputStream(body.getBytes()); DefaultJerseyHandler.this.handle(vertxRequest, inputStream); }); } else { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request: " + vertxRequest.method() + " " + vertxRequest.uri()); } DefaultJerseyHandler.this.handle(vertxRequest, null); } } @Inject DefaultJerseyHandler(
Provider<VertxContainer> containerProvider,
ContainerResponseWriterProvider responseWriterProvider,
List<VertxRequestProcessor> requestProcessors); @Override URI getBaseUri(); int getMaxBodySize(); @Override ApplicationHandlerDelegate getDelegate(); @Override VertxContainer getContainer(); @Override JerseyHandler setContainer(VertxContainer container); @Override void handle(final HttpServerRequest vertxRequest); }
|
@Test public void testHandle_RequestProcessors() throws Exception { when(request.headers()).thenReturn(mock(MultiMap.class)); when(request.method()).thenReturn(HttpMethod.GET); InputStream inputStream = null; VertxRequestProcessor rp1 = mock(VertxRequestProcessor.class); VertxRequestProcessor rp2 = mock(VertxRequestProcessor.class); requestProcessors.add(rp1); requestProcessors.add(rp2); jerseyHandler.handle(request, inputStream); verify(rp1).process(any(HttpServerRequest.class), any(ContainerRequest.class), endHandlerCaptor.capture()); endHandlerCaptor.getValue().handle(null); verify(rp2).process(any(HttpServerRequest.class), any(ContainerRequest.class), endHandlerCaptor.capture()); endHandlerCaptor.getValue().handle(null); verify(applicationHandlerDelegate).handle(any(ContainerRequest.class)); }
|
@Override public void handle(final HttpServerRequest vertxRequest) { if (shouldReadData(vertxRequest)) { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request and read body: " + vertxRequest.method() + " " + vertxRequest.uri()); } final Buffer body = Buffer.buffer(); vertxRequest.handler(buffer -> { body.appendBuffer(buffer); if (body.length() > getMaxBodySize()) { throw new RuntimeException("The input stream has exceeded the max allowed body size " + getMaxBodySize() + "."); } }); vertxRequest.endHandler(aVoid -> { InputStream inputStream = new ByteArrayInputStream(body.getBytes()); DefaultJerseyHandler.this.handle(vertxRequest, inputStream); }); } else { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request: " + vertxRequest.method() + " " + vertxRequest.uri()); } DefaultJerseyHandler.this.handle(vertxRequest, null); } }
|
DefaultJerseyHandler implements JerseyHandler { @Override public void handle(final HttpServerRequest vertxRequest) { if (shouldReadData(vertxRequest)) { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request and read body: " + vertxRequest.method() + " " + vertxRequest.uri()); } final Buffer body = Buffer.buffer(); vertxRequest.handler(buffer -> { body.appendBuffer(buffer); if (body.length() > getMaxBodySize()) { throw new RuntimeException("The input stream has exceeded the max allowed body size " + getMaxBodySize() + "."); } }); vertxRequest.endHandler(aVoid -> { InputStream inputStream = new ByteArrayInputStream(body.getBytes()); DefaultJerseyHandler.this.handle(vertxRequest, inputStream); }); } else { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request: " + vertxRequest.method() + " " + vertxRequest.uri()); } DefaultJerseyHandler.this.handle(vertxRequest, null); } } }
|
DefaultJerseyHandler implements JerseyHandler { @Override public void handle(final HttpServerRequest vertxRequest) { if (shouldReadData(vertxRequest)) { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request and read body: " + vertxRequest.method() + " " + vertxRequest.uri()); } final Buffer body = Buffer.buffer(); vertxRequest.handler(buffer -> { body.appendBuffer(buffer); if (body.length() > getMaxBodySize()) { throw new RuntimeException("The input stream has exceeded the max allowed body size " + getMaxBodySize() + "."); } }); vertxRequest.endHandler(aVoid -> { InputStream inputStream = new ByteArrayInputStream(body.getBytes()); DefaultJerseyHandler.this.handle(vertxRequest, inputStream); }); } else { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request: " + vertxRequest.method() + " " + vertxRequest.uri()); } DefaultJerseyHandler.this.handle(vertxRequest, null); } } @Inject DefaultJerseyHandler(
Provider<VertxContainer> containerProvider,
ContainerResponseWriterProvider responseWriterProvider,
List<VertxRequestProcessor> requestProcessors); }
|
DefaultJerseyHandler implements JerseyHandler { @Override public void handle(final HttpServerRequest vertxRequest) { if (shouldReadData(vertxRequest)) { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request and read body: " + vertxRequest.method() + " " + vertxRequest.uri()); } final Buffer body = Buffer.buffer(); vertxRequest.handler(buffer -> { body.appendBuffer(buffer); if (body.length() > getMaxBodySize()) { throw new RuntimeException("The input stream has exceeded the max allowed body size " + getMaxBodySize() + "."); } }); vertxRequest.endHandler(aVoid -> { InputStream inputStream = new ByteArrayInputStream(body.getBytes()); DefaultJerseyHandler.this.handle(vertxRequest, inputStream); }); } else { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request: " + vertxRequest.method() + " " + vertxRequest.uri()); } DefaultJerseyHandler.this.handle(vertxRequest, null); } } @Inject DefaultJerseyHandler(
Provider<VertxContainer> containerProvider,
ContainerResponseWriterProvider responseWriterProvider,
List<VertxRequestProcessor> requestProcessors); @Override URI getBaseUri(); int getMaxBodySize(); @Override ApplicationHandlerDelegate getDelegate(); @Override VertxContainer getContainer(); @Override JerseyHandler setContainer(VertxContainer container); @Override void handle(final HttpServerRequest vertxRequest); }
|
DefaultJerseyHandler implements JerseyHandler { @Override public void handle(final HttpServerRequest vertxRequest) { if (shouldReadData(vertxRequest)) { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request and read body: " + vertxRequest.method() + " " + vertxRequest.uri()); } final Buffer body = Buffer.buffer(); vertxRequest.handler(buffer -> { body.appendBuffer(buffer); if (body.length() > getMaxBodySize()) { throw new RuntimeException("The input stream has exceeded the max allowed body size " + getMaxBodySize() + "."); } }); vertxRequest.endHandler(aVoid -> { InputStream inputStream = new ByteArrayInputStream(body.getBytes()); DefaultJerseyHandler.this.handle(vertxRequest, inputStream); }); } else { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request: " + vertxRequest.method() + " " + vertxRequest.uri()); } DefaultJerseyHandler.this.handle(vertxRequest, null); } } @Inject DefaultJerseyHandler(
Provider<VertxContainer> containerProvider,
ContainerResponseWriterProvider responseWriterProvider,
List<VertxRequestProcessor> requestProcessors); @Override URI getBaseUri(); int getMaxBodySize(); @Override ApplicationHandlerDelegate getDelegate(); @Override VertxContainer getContainer(); @Override JerseyHandler setContainer(VertxContainer container); @Override void handle(final HttpServerRequest vertxRequest); }
|
@Test public void testHandle_RequestProcessors_Throw() throws Exception { when(request.headers()).thenReturn(mock(MultiMap.class)); when(request.method()).thenReturn(HttpMethod.GET); InputStream inputStream = null; VertxRequestProcessor rp1 = mock(VertxRequestProcessor.class); VertxRequestProcessor rp2 = mock(VertxRequestProcessor.class); when(response.setStatusCode(anyInt())).thenReturn(response); doThrow(RuntimeException.class).when(rp2).process(any(), any(), any()); requestProcessors.add(rp1); requestProcessors.add(rp2); jerseyHandler.handle(request, inputStream); verify(rp1).process(any(), any(), endHandlerCaptor.capture()); endHandlerCaptor.getValue().handle(null); verify(rp2).process(any(), any(), any()); verify(response).setStatusCode(eq(HttpResponseStatus.INTERNAL_SERVER_ERROR.code())); verify(response).end(); }
|
@Override public void handle(final HttpServerRequest vertxRequest) { if (shouldReadData(vertxRequest)) { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request and read body: " + vertxRequest.method() + " " + vertxRequest.uri()); } final Buffer body = Buffer.buffer(); vertxRequest.handler(buffer -> { body.appendBuffer(buffer); if (body.length() > getMaxBodySize()) { throw new RuntimeException("The input stream has exceeded the max allowed body size " + getMaxBodySize() + "."); } }); vertxRequest.endHandler(aVoid -> { InputStream inputStream = new ByteArrayInputStream(body.getBytes()); DefaultJerseyHandler.this.handle(vertxRequest, inputStream); }); } else { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request: " + vertxRequest.method() + " " + vertxRequest.uri()); } DefaultJerseyHandler.this.handle(vertxRequest, null); } }
|
DefaultJerseyHandler implements JerseyHandler { @Override public void handle(final HttpServerRequest vertxRequest) { if (shouldReadData(vertxRequest)) { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request and read body: " + vertxRequest.method() + " " + vertxRequest.uri()); } final Buffer body = Buffer.buffer(); vertxRequest.handler(buffer -> { body.appendBuffer(buffer); if (body.length() > getMaxBodySize()) { throw new RuntimeException("The input stream has exceeded the max allowed body size " + getMaxBodySize() + "."); } }); vertxRequest.endHandler(aVoid -> { InputStream inputStream = new ByteArrayInputStream(body.getBytes()); DefaultJerseyHandler.this.handle(vertxRequest, inputStream); }); } else { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request: " + vertxRequest.method() + " " + vertxRequest.uri()); } DefaultJerseyHandler.this.handle(vertxRequest, null); } } }
|
DefaultJerseyHandler implements JerseyHandler { @Override public void handle(final HttpServerRequest vertxRequest) { if (shouldReadData(vertxRequest)) { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request and read body: " + vertxRequest.method() + " " + vertxRequest.uri()); } final Buffer body = Buffer.buffer(); vertxRequest.handler(buffer -> { body.appendBuffer(buffer); if (body.length() > getMaxBodySize()) { throw new RuntimeException("The input stream has exceeded the max allowed body size " + getMaxBodySize() + "."); } }); vertxRequest.endHandler(aVoid -> { InputStream inputStream = new ByteArrayInputStream(body.getBytes()); DefaultJerseyHandler.this.handle(vertxRequest, inputStream); }); } else { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request: " + vertxRequest.method() + " " + vertxRequest.uri()); } DefaultJerseyHandler.this.handle(vertxRequest, null); } } @Inject DefaultJerseyHandler(
Provider<VertxContainer> containerProvider,
ContainerResponseWriterProvider responseWriterProvider,
List<VertxRequestProcessor> requestProcessors); }
|
DefaultJerseyHandler implements JerseyHandler { @Override public void handle(final HttpServerRequest vertxRequest) { if (shouldReadData(vertxRequest)) { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request and read body: " + vertxRequest.method() + " " + vertxRequest.uri()); } final Buffer body = Buffer.buffer(); vertxRequest.handler(buffer -> { body.appendBuffer(buffer); if (body.length() > getMaxBodySize()) { throw new RuntimeException("The input stream has exceeded the max allowed body size " + getMaxBodySize() + "."); } }); vertxRequest.endHandler(aVoid -> { InputStream inputStream = new ByteArrayInputStream(body.getBytes()); DefaultJerseyHandler.this.handle(vertxRequest, inputStream); }); } else { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request: " + vertxRequest.method() + " " + vertxRequest.uri()); } DefaultJerseyHandler.this.handle(vertxRequest, null); } } @Inject DefaultJerseyHandler(
Provider<VertxContainer> containerProvider,
ContainerResponseWriterProvider responseWriterProvider,
List<VertxRequestProcessor> requestProcessors); @Override URI getBaseUri(); int getMaxBodySize(); @Override ApplicationHandlerDelegate getDelegate(); @Override VertxContainer getContainer(); @Override JerseyHandler setContainer(VertxContainer container); @Override void handle(final HttpServerRequest vertxRequest); }
|
DefaultJerseyHandler implements JerseyHandler { @Override public void handle(final HttpServerRequest vertxRequest) { if (shouldReadData(vertxRequest)) { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request and read body: " + vertxRequest.method() + " " + vertxRequest.uri()); } final Buffer body = Buffer.buffer(); vertxRequest.handler(buffer -> { body.appendBuffer(buffer); if (body.length() > getMaxBodySize()) { throw new RuntimeException("The input stream has exceeded the max allowed body size " + getMaxBodySize() + "."); } }); vertxRequest.endHandler(aVoid -> { InputStream inputStream = new ByteArrayInputStream(body.getBytes()); DefaultJerseyHandler.this.handle(vertxRequest, inputStream); }); } else { if (logger.isDebugEnabled()) { logger.debug("DefaultJerseyHandler - handle request: " + vertxRequest.method() + " " + vertxRequest.uri()); } DefaultJerseyHandler.this.handle(vertxRequest, null); } } @Inject DefaultJerseyHandler(
Provider<VertxContainer> containerProvider,
ContainerResponseWriterProvider responseWriterProvider,
List<VertxRequestProcessor> requestProcessors); @Override URI getBaseUri(); int getMaxBodySize(); @Override ApplicationHandlerDelegate getDelegate(); @Override VertxContainer getContainer(); @Override JerseyHandler setContainer(VertxContainer container); @Override void handle(final HttpServerRequest vertxRequest); }
|
@Test public void testCreateServer_Success() throws Exception { when(result.succeeded()).thenReturn(true); whenJerseyServer.createServer() .then(done.onFulfilled, done.onRejected); verify(server).start(any(), any(), handlerCaptor.capture()); handlerCaptor.getValue().handle(result); done.assertFulfilled(); }
|
@Override public Promise<JerseyServer> createServer(@Nullable JerseyServerOptions options, @Nullable JerseyOptions jerseyOptions) { final Deferred<JerseyServer> d = when.defer(); try { JerseyServer jerseyServer = jerseyServerProvider.get(); jerseyServer.start(options, jerseyOptions, result -> { if (result.succeeded()) { d.resolve(jerseyServer); } else { d.reject(result.cause()); } }); } catch (RuntimeException e) { d.reject(e); } return d.getPromise(); }
|
DefaultWhenJerseyServer implements WhenJerseyServer { @Override public Promise<JerseyServer> createServer(@Nullable JerseyServerOptions options, @Nullable JerseyOptions jerseyOptions) { final Deferred<JerseyServer> d = when.defer(); try { JerseyServer jerseyServer = jerseyServerProvider.get(); jerseyServer.start(options, jerseyOptions, result -> { if (result.succeeded()) { d.resolve(jerseyServer); } else { d.reject(result.cause()); } }); } catch (RuntimeException e) { d.reject(e); } return d.getPromise(); } }
|
DefaultWhenJerseyServer implements WhenJerseyServer { @Override public Promise<JerseyServer> createServer(@Nullable JerseyServerOptions options, @Nullable JerseyOptions jerseyOptions) { final Deferred<JerseyServer> d = when.defer(); try { JerseyServer jerseyServer = jerseyServerProvider.get(); jerseyServer.start(options, jerseyOptions, result -> { if (result.succeeded()) { d.resolve(jerseyServer); } else { d.reject(result.cause()); } }); } catch (RuntimeException e) { d.reject(e); } return d.getPromise(); } @Inject DefaultWhenJerseyServer(Vertx vertx, Provider<JerseyServer> jerseyServerProvider, When when); }
|
DefaultWhenJerseyServer implements WhenJerseyServer { @Override public Promise<JerseyServer> createServer(@Nullable JerseyServerOptions options, @Nullable JerseyOptions jerseyOptions) { final Deferred<JerseyServer> d = when.defer(); try { JerseyServer jerseyServer = jerseyServerProvider.get(); jerseyServer.start(options, jerseyOptions, result -> { if (result.succeeded()) { d.resolve(jerseyServer); } else { d.reject(result.cause()); } }); } catch (RuntimeException e) { d.reject(e); } return d.getPromise(); } @Inject DefaultWhenJerseyServer(Vertx vertx, Provider<JerseyServer> jerseyServerProvider, When when); @Override Promise<JerseyServer> createServer(@Nullable JerseyServerOptions options, @Nullable JerseyOptions jerseyOptions); @Override Promise<String> createServerSimple(); }
|
DefaultWhenJerseyServer implements WhenJerseyServer { @Override public Promise<JerseyServer> createServer(@Nullable JerseyServerOptions options, @Nullable JerseyOptions jerseyOptions) { final Deferred<JerseyServer> d = when.defer(); try { JerseyServer jerseyServer = jerseyServerProvider.get(); jerseyServer.start(options, jerseyOptions, result -> { if (result.succeeded()) { d.resolve(jerseyServer); } else { d.reject(result.cause()); } }); } catch (RuntimeException e) { d.reject(e); } return d.getPromise(); } @Inject DefaultWhenJerseyServer(Vertx vertx, Provider<JerseyServer> jerseyServerProvider, When when); @Override Promise<JerseyServer> createServer(@Nullable JerseyServerOptions options, @Nullable JerseyOptions jerseyOptions); @Override Promise<String> createServerSimple(); }
|
@Test public void testShouldReadData() throws Exception { boolean result; DefaultHttpHeaders headers = new DefaultHttpHeaders(); headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_OCTET_STREAM); when(request.method()).thenReturn(HttpMethod.GET).thenReturn(HttpMethod.PUT); when(request.headers()).thenReturn(new HeadersAdaptor(headers)); result = jerseyHandler.shouldReadData(request); assertFalse(result); result = jerseyHandler.shouldReadData(request); assertFalse(result); headers.clear(); headers.add(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN); result = jerseyHandler.shouldReadData(request); assertTrue(result); headers.clear(); headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON); result = jerseyHandler.shouldReadData(request); assertTrue(result); headers.clear(); headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED); when(request.method()).thenReturn(HttpMethod.POST); result = jerseyHandler.shouldReadData(request); assertTrue(result); headers.clear(); headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML); result = jerseyHandler.shouldReadData(request); assertTrue(result); headers.clear(); headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED + "; charset=UTF-8"); result = jerseyHandler.shouldReadData(request); assertTrue(result); headers.clear(); headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED); when(request.method()).thenReturn(HttpMethod.PATCH); result = jerseyHandler.shouldReadData(request); assertTrue(result); headers.clear(); headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON); result = jerseyHandler.shouldReadData(request); assertTrue(result); headers.clear(); headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML); result = jerseyHandler.shouldReadData(request); assertTrue(result); headers.clear(); headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED + "; charset=UTF-8"); result = jerseyHandler.shouldReadData(request); assertTrue(result); }
|
protected boolean shouldReadData(HttpServerRequest vertxRequest) { HttpMethod method = vertxRequest.method(); if (!(HttpMethod.POST == method || HttpMethod.PUT == method || HttpMethod.PATCH == method)) { return false; } String contentType = vertxRequest.headers().get(HttpHeaders.CONTENT_TYPE); if (contentType == null || contentType.isEmpty()) { return true; } MediaType mediaType = MediaType.valueOf(contentType); if (MediaType.TEXT_PLAIN_TYPE.getType().equals(mediaType.getType())) { return true; } String applicationType = MediaType.APPLICATION_FORM_URLENCODED_TYPE.getType(); if (!applicationType.equalsIgnoreCase(mediaType.getType())) { return false; } if (mediaType.getSubtype().equalsIgnoreCase(MediaType.APPLICATION_FORM_URLENCODED_TYPE.getSubtype())) { if (!mediaType.getParameters().isEmpty()) { vertxRequest.headers().remove(HttpHeaders.CONTENT_TYPE); vertxRequest.headers().add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED); } return true; } return MediaType.APPLICATION_JSON_TYPE.getSubtype().equalsIgnoreCase(mediaType.getSubtype()) || MediaType.APPLICATION_XML_TYPE.getSubtype().equalsIgnoreCase(mediaType.getSubtype()); }
|
DefaultJerseyHandler implements JerseyHandler { protected boolean shouldReadData(HttpServerRequest vertxRequest) { HttpMethod method = vertxRequest.method(); if (!(HttpMethod.POST == method || HttpMethod.PUT == method || HttpMethod.PATCH == method)) { return false; } String contentType = vertxRequest.headers().get(HttpHeaders.CONTENT_TYPE); if (contentType == null || contentType.isEmpty()) { return true; } MediaType mediaType = MediaType.valueOf(contentType); if (MediaType.TEXT_PLAIN_TYPE.getType().equals(mediaType.getType())) { return true; } String applicationType = MediaType.APPLICATION_FORM_URLENCODED_TYPE.getType(); if (!applicationType.equalsIgnoreCase(mediaType.getType())) { return false; } if (mediaType.getSubtype().equalsIgnoreCase(MediaType.APPLICATION_FORM_URLENCODED_TYPE.getSubtype())) { if (!mediaType.getParameters().isEmpty()) { vertxRequest.headers().remove(HttpHeaders.CONTENT_TYPE); vertxRequest.headers().add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED); } return true; } return MediaType.APPLICATION_JSON_TYPE.getSubtype().equalsIgnoreCase(mediaType.getSubtype()) || MediaType.APPLICATION_XML_TYPE.getSubtype().equalsIgnoreCase(mediaType.getSubtype()); } }
|
DefaultJerseyHandler implements JerseyHandler { protected boolean shouldReadData(HttpServerRequest vertxRequest) { HttpMethod method = vertxRequest.method(); if (!(HttpMethod.POST == method || HttpMethod.PUT == method || HttpMethod.PATCH == method)) { return false; } String contentType = vertxRequest.headers().get(HttpHeaders.CONTENT_TYPE); if (contentType == null || contentType.isEmpty()) { return true; } MediaType mediaType = MediaType.valueOf(contentType); if (MediaType.TEXT_PLAIN_TYPE.getType().equals(mediaType.getType())) { return true; } String applicationType = MediaType.APPLICATION_FORM_URLENCODED_TYPE.getType(); if (!applicationType.equalsIgnoreCase(mediaType.getType())) { return false; } if (mediaType.getSubtype().equalsIgnoreCase(MediaType.APPLICATION_FORM_URLENCODED_TYPE.getSubtype())) { if (!mediaType.getParameters().isEmpty()) { vertxRequest.headers().remove(HttpHeaders.CONTENT_TYPE); vertxRequest.headers().add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED); } return true; } return MediaType.APPLICATION_JSON_TYPE.getSubtype().equalsIgnoreCase(mediaType.getSubtype()) || MediaType.APPLICATION_XML_TYPE.getSubtype().equalsIgnoreCase(mediaType.getSubtype()); } @Inject DefaultJerseyHandler(
Provider<VertxContainer> containerProvider,
ContainerResponseWriterProvider responseWriterProvider,
List<VertxRequestProcessor> requestProcessors); }
|
DefaultJerseyHandler implements JerseyHandler { protected boolean shouldReadData(HttpServerRequest vertxRequest) { HttpMethod method = vertxRequest.method(); if (!(HttpMethod.POST == method || HttpMethod.PUT == method || HttpMethod.PATCH == method)) { return false; } String contentType = vertxRequest.headers().get(HttpHeaders.CONTENT_TYPE); if (contentType == null || contentType.isEmpty()) { return true; } MediaType mediaType = MediaType.valueOf(contentType); if (MediaType.TEXT_PLAIN_TYPE.getType().equals(mediaType.getType())) { return true; } String applicationType = MediaType.APPLICATION_FORM_URLENCODED_TYPE.getType(); if (!applicationType.equalsIgnoreCase(mediaType.getType())) { return false; } if (mediaType.getSubtype().equalsIgnoreCase(MediaType.APPLICATION_FORM_URLENCODED_TYPE.getSubtype())) { if (!mediaType.getParameters().isEmpty()) { vertxRequest.headers().remove(HttpHeaders.CONTENT_TYPE); vertxRequest.headers().add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED); } return true; } return MediaType.APPLICATION_JSON_TYPE.getSubtype().equalsIgnoreCase(mediaType.getSubtype()) || MediaType.APPLICATION_XML_TYPE.getSubtype().equalsIgnoreCase(mediaType.getSubtype()); } @Inject DefaultJerseyHandler(
Provider<VertxContainer> containerProvider,
ContainerResponseWriterProvider responseWriterProvider,
List<VertxRequestProcessor> requestProcessors); @Override URI getBaseUri(); int getMaxBodySize(); @Override ApplicationHandlerDelegate getDelegate(); @Override VertxContainer getContainer(); @Override JerseyHandler setContainer(VertxContainer container); @Override void handle(final HttpServerRequest vertxRequest); }
|
DefaultJerseyHandler implements JerseyHandler { protected boolean shouldReadData(HttpServerRequest vertxRequest) { HttpMethod method = vertxRequest.method(); if (!(HttpMethod.POST == method || HttpMethod.PUT == method || HttpMethod.PATCH == method)) { return false; } String contentType = vertxRequest.headers().get(HttpHeaders.CONTENT_TYPE); if (contentType == null || contentType.isEmpty()) { return true; } MediaType mediaType = MediaType.valueOf(contentType); if (MediaType.TEXT_PLAIN_TYPE.getType().equals(mediaType.getType())) { return true; } String applicationType = MediaType.APPLICATION_FORM_URLENCODED_TYPE.getType(); if (!applicationType.equalsIgnoreCase(mediaType.getType())) { return false; } if (mediaType.getSubtype().equalsIgnoreCase(MediaType.APPLICATION_FORM_URLENCODED_TYPE.getSubtype())) { if (!mediaType.getParameters().isEmpty()) { vertxRequest.headers().remove(HttpHeaders.CONTENT_TYPE); vertxRequest.headers().add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED); } return true; } return MediaType.APPLICATION_JSON_TYPE.getSubtype().equalsIgnoreCase(mediaType.getSubtype()) || MediaType.APPLICATION_XML_TYPE.getSubtype().equalsIgnoreCase(mediaType.getSubtype()); } @Inject DefaultJerseyHandler(
Provider<VertxContainer> containerProvider,
ContainerResponseWriterProvider responseWriterProvider,
List<VertxRequestProcessor> requestProcessors); @Override URI getBaseUri(); int getMaxBodySize(); @Override ApplicationHandlerDelegate getDelegate(); @Override VertxContainer getContainer(); @Override JerseyHandler setContainer(VertxContainer container); @Override void handle(final HttpServerRequest vertxRequest); }
|
@Test public void testGetAbsoluteURI() throws Exception { URI uri; String absoluteUri = "http: String host = "test.englishtown.com"; String badUrl = "http: HttpServerRequest request = mock(HttpServerRequest.class); when(request.absoluteURI()).thenReturn(absoluteUri).thenThrow(new IllegalArgumentException()); when(request.uri()).thenReturn(badUrl); when(request.headers()).thenReturn(headers); when(headers.get(eq(HttpHeaders.HOST))).thenReturn(host); uri = jerseyHandler.getAbsoluteURI(request); assertEquals("http: uri = jerseyHandler.getAbsoluteURI(request); assertEquals("http: }
|
protected URI getAbsoluteURI(HttpServerRequest vertxRequest) { URI absoluteUri; String hostAndPort = vertxRequest.headers().get(HttpHeaders.HOST); try { absoluteUri = URI.create(vertxRequest.absoluteURI()); if (hostAndPort != null && !hostAndPort.isEmpty()) { String[] parts = hostAndPort.split(":"); String host = parts[0]; int port = (parts.length > 1 ? Integer.valueOf(parts[1]) : -1); if (!host.equalsIgnoreCase(absoluteUri.getHost()) || port != absoluteUri.getPort()) { absoluteUri = UriBuilder.fromUri(absoluteUri) .host(host) .port(port) .build(); } } return absoluteUri; } catch (IllegalArgumentException e) { String uri = vertxRequest.uri(); if (!uri.contains("?")) { throw e; } try { logger.warn("Invalid URI: " + uri + ". Attempting to parse query string.", e); QueryStringDecoder decoder = new QueryStringDecoder(uri); StringBuilder sb = new StringBuilder(decoder.path() + "?"); for (Map.Entry<String, List<String>> p : decoder.parameters().entrySet()) { for (String value : p.getValue()) { sb.append(p.getKey()).append("=").append(URLEncoder.encode(value, "UTF-8")); } } return URI.create(sb.toString()); } catch (Exception e1) { throw new RuntimeException(e1); } } }
|
DefaultJerseyHandler implements JerseyHandler { protected URI getAbsoluteURI(HttpServerRequest vertxRequest) { URI absoluteUri; String hostAndPort = vertxRequest.headers().get(HttpHeaders.HOST); try { absoluteUri = URI.create(vertxRequest.absoluteURI()); if (hostAndPort != null && !hostAndPort.isEmpty()) { String[] parts = hostAndPort.split(":"); String host = parts[0]; int port = (parts.length > 1 ? Integer.valueOf(parts[1]) : -1); if (!host.equalsIgnoreCase(absoluteUri.getHost()) || port != absoluteUri.getPort()) { absoluteUri = UriBuilder.fromUri(absoluteUri) .host(host) .port(port) .build(); } } return absoluteUri; } catch (IllegalArgumentException e) { String uri = vertxRequest.uri(); if (!uri.contains("?")) { throw e; } try { logger.warn("Invalid URI: " + uri + ". Attempting to parse query string.", e); QueryStringDecoder decoder = new QueryStringDecoder(uri); StringBuilder sb = new StringBuilder(decoder.path() + "?"); for (Map.Entry<String, List<String>> p : decoder.parameters().entrySet()) { for (String value : p.getValue()) { sb.append(p.getKey()).append("=").append(URLEncoder.encode(value, "UTF-8")); } } return URI.create(sb.toString()); } catch (Exception e1) { throw new RuntimeException(e1); } } } }
|
DefaultJerseyHandler implements JerseyHandler { protected URI getAbsoluteURI(HttpServerRequest vertxRequest) { URI absoluteUri; String hostAndPort = vertxRequest.headers().get(HttpHeaders.HOST); try { absoluteUri = URI.create(vertxRequest.absoluteURI()); if (hostAndPort != null && !hostAndPort.isEmpty()) { String[] parts = hostAndPort.split(":"); String host = parts[0]; int port = (parts.length > 1 ? Integer.valueOf(parts[1]) : -1); if (!host.equalsIgnoreCase(absoluteUri.getHost()) || port != absoluteUri.getPort()) { absoluteUri = UriBuilder.fromUri(absoluteUri) .host(host) .port(port) .build(); } } return absoluteUri; } catch (IllegalArgumentException e) { String uri = vertxRequest.uri(); if (!uri.contains("?")) { throw e; } try { logger.warn("Invalid URI: " + uri + ". Attempting to parse query string.", e); QueryStringDecoder decoder = new QueryStringDecoder(uri); StringBuilder sb = new StringBuilder(decoder.path() + "?"); for (Map.Entry<String, List<String>> p : decoder.parameters().entrySet()) { for (String value : p.getValue()) { sb.append(p.getKey()).append("=").append(URLEncoder.encode(value, "UTF-8")); } } return URI.create(sb.toString()); } catch (Exception e1) { throw new RuntimeException(e1); } } } @Inject DefaultJerseyHandler(
Provider<VertxContainer> containerProvider,
ContainerResponseWriterProvider responseWriterProvider,
List<VertxRequestProcessor> requestProcessors); }
|
DefaultJerseyHandler implements JerseyHandler { protected URI getAbsoluteURI(HttpServerRequest vertxRequest) { URI absoluteUri; String hostAndPort = vertxRequest.headers().get(HttpHeaders.HOST); try { absoluteUri = URI.create(vertxRequest.absoluteURI()); if (hostAndPort != null && !hostAndPort.isEmpty()) { String[] parts = hostAndPort.split(":"); String host = parts[0]; int port = (parts.length > 1 ? Integer.valueOf(parts[1]) : -1); if (!host.equalsIgnoreCase(absoluteUri.getHost()) || port != absoluteUri.getPort()) { absoluteUri = UriBuilder.fromUri(absoluteUri) .host(host) .port(port) .build(); } } return absoluteUri; } catch (IllegalArgumentException e) { String uri = vertxRequest.uri(); if (!uri.contains("?")) { throw e; } try { logger.warn("Invalid URI: " + uri + ". Attempting to parse query string.", e); QueryStringDecoder decoder = new QueryStringDecoder(uri); StringBuilder sb = new StringBuilder(decoder.path() + "?"); for (Map.Entry<String, List<String>> p : decoder.parameters().entrySet()) { for (String value : p.getValue()) { sb.append(p.getKey()).append("=").append(URLEncoder.encode(value, "UTF-8")); } } return URI.create(sb.toString()); } catch (Exception e1) { throw new RuntimeException(e1); } } } @Inject DefaultJerseyHandler(
Provider<VertxContainer> containerProvider,
ContainerResponseWriterProvider responseWriterProvider,
List<VertxRequestProcessor> requestProcessors); @Override URI getBaseUri(); int getMaxBodySize(); @Override ApplicationHandlerDelegate getDelegate(); @Override VertxContainer getContainer(); @Override JerseyHandler setContainer(VertxContainer container); @Override void handle(final HttpServerRequest vertxRequest); }
|
DefaultJerseyHandler implements JerseyHandler { protected URI getAbsoluteURI(HttpServerRequest vertxRequest) { URI absoluteUri; String hostAndPort = vertxRequest.headers().get(HttpHeaders.HOST); try { absoluteUri = URI.create(vertxRequest.absoluteURI()); if (hostAndPort != null && !hostAndPort.isEmpty()) { String[] parts = hostAndPort.split(":"); String host = parts[0]; int port = (parts.length > 1 ? Integer.valueOf(parts[1]) : -1); if (!host.equalsIgnoreCase(absoluteUri.getHost()) || port != absoluteUri.getPort()) { absoluteUri = UriBuilder.fromUri(absoluteUri) .host(host) .port(port) .build(); } } return absoluteUri; } catch (IllegalArgumentException e) { String uri = vertxRequest.uri(); if (!uri.contains("?")) { throw e; } try { logger.warn("Invalid URI: " + uri + ". Attempting to parse query string.", e); QueryStringDecoder decoder = new QueryStringDecoder(uri); StringBuilder sb = new StringBuilder(decoder.path() + "?"); for (Map.Entry<String, List<String>> p : decoder.parameters().entrySet()) { for (String value : p.getValue()) { sb.append(p.getKey()).append("=").append(URLEncoder.encode(value, "UTF-8")); } } return URI.create(sb.toString()); } catch (Exception e1) { throw new RuntimeException(e1); } } } @Inject DefaultJerseyHandler(
Provider<VertxContainer> containerProvider,
ContainerResponseWriterProvider responseWriterProvider,
List<VertxRequestProcessor> requestProcessors); @Override URI getBaseUri(); int getMaxBodySize(); @Override ApplicationHandlerDelegate getDelegate(); @Override VertxContainer getContainer(); @Override JerseyHandler setContainer(VertxContainer container); @Override void handle(final HttpServerRequest vertxRequest); }
|
@Test public void testGetBaseURI() throws Exception { URI baseUri = URI.create("/test"); when(options.getBaseUri()).thenReturn(baseUri); URI result = jerseyHandler.getBaseUri(); assertEquals(baseUri, result); }
|
@Override public URI getBaseUri() { if (baseUri == null) { baseUri = getContainer().getOptions().getBaseUri(); if (baseUri == null) { throw new IllegalStateException("baseUri is null, have you called init() first?"); } } return baseUri; }
|
DefaultJerseyHandler implements JerseyHandler { @Override public URI getBaseUri() { if (baseUri == null) { baseUri = getContainer().getOptions().getBaseUri(); if (baseUri == null) { throw new IllegalStateException("baseUri is null, have you called init() first?"); } } return baseUri; } }
|
DefaultJerseyHandler implements JerseyHandler { @Override public URI getBaseUri() { if (baseUri == null) { baseUri = getContainer().getOptions().getBaseUri(); if (baseUri == null) { throw new IllegalStateException("baseUri is null, have you called init() first?"); } } return baseUri; } @Inject DefaultJerseyHandler(
Provider<VertxContainer> containerProvider,
ContainerResponseWriterProvider responseWriterProvider,
List<VertxRequestProcessor> requestProcessors); }
|
DefaultJerseyHandler implements JerseyHandler { @Override public URI getBaseUri() { if (baseUri == null) { baseUri = getContainer().getOptions().getBaseUri(); if (baseUri == null) { throw new IllegalStateException("baseUri is null, have you called init() first?"); } } return baseUri; } @Inject DefaultJerseyHandler(
Provider<VertxContainer> containerProvider,
ContainerResponseWriterProvider responseWriterProvider,
List<VertxRequestProcessor> requestProcessors); @Override URI getBaseUri(); int getMaxBodySize(); @Override ApplicationHandlerDelegate getDelegate(); @Override VertxContainer getContainer(); @Override JerseyHandler setContainer(VertxContainer container); @Override void handle(final HttpServerRequest vertxRequest); }
|
DefaultJerseyHandler implements JerseyHandler { @Override public URI getBaseUri() { if (baseUri == null) { baseUri = getContainer().getOptions().getBaseUri(); if (baseUri == null) { throw new IllegalStateException("baseUri is null, have you called init() first?"); } } return baseUri; } @Inject DefaultJerseyHandler(
Provider<VertxContainer> containerProvider,
ContainerResponseWriterProvider responseWriterProvider,
List<VertxRequestProcessor> requestProcessors); @Override URI getBaseUri(); int getMaxBodySize(); @Override ApplicationHandlerDelegate getDelegate(); @Override VertxContainer getContainer(); @Override JerseyHandler setContainer(VertxContainer container); @Override void handle(final HttpServerRequest vertxRequest); }
|
@Test public void testWriteResponseStatusAndHeaders() throws Exception { ContainerResponse cr = mock(ContainerResponse.class); MultivaluedMap<String, String> headers = new MultivaluedHashMap<>(); when(cr.getStatusInfo()).thenReturn(mock(Response.StatusType.class)); when(cr.getStringHeaders()).thenReturn(headers); VertxResponseProcessor processor1 = mock(VertxResponseProcessor.class); VertxResponseProcessor processor2 = mock(VertxResponseProcessor.class); responseProcessors.add(processor1); responseProcessors.add(processor2); headers.add("x-test", "custom header"); OutputStream outputStream = writer.writeResponseStatusAndHeaders(15, cr); assertNotNull(outputStream); verify(response, times(1)).setStatusCode(anyInt()); verify(response, times(1)).setStatusMessage(anyString()); verify(response, times(1)).putHeader(anyString(), anyListOf(String.class)); verify(processor1).process(eq(response), eq(cr)); verify(processor2).process(eq(response), eq(cr)); writer.writeResponseStatusAndHeaders(-1, cr); verify(response, times(2)).putHeader(anyString(), anyListOf(String.class)); }
|
@Override public OutputStream writeResponseStatusAndHeaders(long contentLength, ContainerResponse responseContext) throws ContainerException { jerseyResponse = responseContext; HttpServerResponse response = vertxRequest.response(); response.setStatusCode(responseContext.getStatus()); response.setStatusMessage(responseContext.getStatusInfo().getReasonPhrase()); if (contentLength != -1) { response.putHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(contentLength)); } for (final Map.Entry<String, List<String>> e : responseContext.getStringHeaders().entrySet()) { response.putHeader(e.getKey(), e.getValue()); } if (!responseProcessors.isEmpty()) { for (VertxResponseProcessor processor : responseProcessors) { processor.process(response, responseContext); } } if (responseContext.isChunked()) { response.setChunked(true); return new VertxChunkedOutputStream(response); } else if (responseContext.hasEntity() && WriteStreamOutput.class.isAssignableFrom(responseContext.getEntityClass())) { WriteStreamOutput writeStreamOutput = (WriteStreamOutput) responseContext.getEntity(); writeStreamOutput.init(response, event -> end()); isWriteStream = true; return new NOPOutputStream(); } else { return new VertxOutputStream(response); } }
|
VertxResponseWriter implements ContainerResponseWriter { @Override public OutputStream writeResponseStatusAndHeaders(long contentLength, ContainerResponse responseContext) throws ContainerException { jerseyResponse = responseContext; HttpServerResponse response = vertxRequest.response(); response.setStatusCode(responseContext.getStatus()); response.setStatusMessage(responseContext.getStatusInfo().getReasonPhrase()); if (contentLength != -1) { response.putHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(contentLength)); } for (final Map.Entry<String, List<String>> e : responseContext.getStringHeaders().entrySet()) { response.putHeader(e.getKey(), e.getValue()); } if (!responseProcessors.isEmpty()) { for (VertxResponseProcessor processor : responseProcessors) { processor.process(response, responseContext); } } if (responseContext.isChunked()) { response.setChunked(true); return new VertxChunkedOutputStream(response); } else if (responseContext.hasEntity() && WriteStreamOutput.class.isAssignableFrom(responseContext.getEntityClass())) { WriteStreamOutput writeStreamOutput = (WriteStreamOutput) responseContext.getEntity(); writeStreamOutput.init(response, event -> end()); isWriteStream = true; return new NOPOutputStream(); } else { return new VertxOutputStream(response); } } }
|
VertxResponseWriter implements ContainerResponseWriter { @Override public OutputStream writeResponseStatusAndHeaders(long contentLength, ContainerResponse responseContext) throws ContainerException { jerseyResponse = responseContext; HttpServerResponse response = vertxRequest.response(); response.setStatusCode(responseContext.getStatus()); response.setStatusMessage(responseContext.getStatusInfo().getReasonPhrase()); if (contentLength != -1) { response.putHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(contentLength)); } for (final Map.Entry<String, List<String>> e : responseContext.getStringHeaders().entrySet()) { response.putHeader(e.getKey(), e.getValue()); } if (!responseProcessors.isEmpty()) { for (VertxResponseProcessor processor : responseProcessors) { processor.process(response, responseContext); } } if (responseContext.isChunked()) { response.setChunked(true); return new VertxChunkedOutputStream(response); } else if (responseContext.hasEntity() && WriteStreamOutput.class.isAssignableFrom(responseContext.getEntityClass())) { WriteStreamOutput writeStreamOutput = (WriteStreamOutput) responseContext.getEntity(); writeStreamOutput.init(response, event -> end()); isWriteStream = true; return new NOPOutputStream(); } else { return new VertxOutputStream(response); } } @Inject VertxResponseWriter(
HttpServerRequest vertxRequest,
Vertx vertx,
List<VertxResponseProcessor> responseProcessors,
List<VertxPostResponseProcessor> postResponseProcessors); }
|
VertxResponseWriter implements ContainerResponseWriter { @Override public OutputStream writeResponseStatusAndHeaders(long contentLength, ContainerResponse responseContext) throws ContainerException { jerseyResponse = responseContext; HttpServerResponse response = vertxRequest.response(); response.setStatusCode(responseContext.getStatus()); response.setStatusMessage(responseContext.getStatusInfo().getReasonPhrase()); if (contentLength != -1) { response.putHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(contentLength)); } for (final Map.Entry<String, List<String>> e : responseContext.getStringHeaders().entrySet()) { response.putHeader(e.getKey(), e.getValue()); } if (!responseProcessors.isEmpty()) { for (VertxResponseProcessor processor : responseProcessors) { processor.process(response, responseContext); } } if (responseContext.isChunked()) { response.setChunked(true); return new VertxChunkedOutputStream(response); } else if (responseContext.hasEntity() && WriteStreamOutput.class.isAssignableFrom(responseContext.getEntityClass())) { WriteStreamOutput writeStreamOutput = (WriteStreamOutput) responseContext.getEntity(); writeStreamOutput.init(response, event -> end()); isWriteStream = true; return new NOPOutputStream(); } else { return new VertxOutputStream(response); } } @Inject VertxResponseWriter(
HttpServerRequest vertxRequest,
Vertx vertx,
List<VertxResponseProcessor> responseProcessors,
List<VertxPostResponseProcessor> postResponseProcessors); @Override OutputStream writeResponseStatusAndHeaders(long contentLength, ContainerResponse responseContext); @Override boolean suspend(long timeOut, TimeUnit timeUnit, TimeoutHandler timeoutHandler); @Override void setSuspendTimeout(long timeOut, TimeUnit timeUnit); @Override void commit(); @Override void failure(Throwable error); @Override boolean enableResponseBuffering(); }
|
VertxResponseWriter implements ContainerResponseWriter { @Override public OutputStream writeResponseStatusAndHeaders(long contentLength, ContainerResponse responseContext) throws ContainerException { jerseyResponse = responseContext; HttpServerResponse response = vertxRequest.response(); response.setStatusCode(responseContext.getStatus()); response.setStatusMessage(responseContext.getStatusInfo().getReasonPhrase()); if (contentLength != -1) { response.putHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(contentLength)); } for (final Map.Entry<String, List<String>> e : responseContext.getStringHeaders().entrySet()) { response.putHeader(e.getKey(), e.getValue()); } if (!responseProcessors.isEmpty()) { for (VertxResponseProcessor processor : responseProcessors) { processor.process(response, responseContext); } } if (responseContext.isChunked()) { response.setChunked(true); return new VertxChunkedOutputStream(response); } else if (responseContext.hasEntity() && WriteStreamOutput.class.isAssignableFrom(responseContext.getEntityClass())) { WriteStreamOutput writeStreamOutput = (WriteStreamOutput) responseContext.getEntity(); writeStreamOutput.init(response, event -> end()); isWriteStream = true; return new NOPOutputStream(); } else { return new VertxOutputStream(response); } } @Inject VertxResponseWriter(
HttpServerRequest vertxRequest,
Vertx vertx,
List<VertxResponseProcessor> responseProcessors,
List<VertxPostResponseProcessor> postResponseProcessors); @Override OutputStream writeResponseStatusAndHeaders(long contentLength, ContainerResponse responseContext); @Override boolean suspend(long timeOut, TimeUnit timeUnit, TimeoutHandler timeoutHandler); @Override void setSuspendTimeout(long timeOut, TimeUnit timeUnit); @Override void commit(); @Override void failure(Throwable error); @Override boolean enableResponseBuffering(); }
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.