@Test
 public void removeConnection() throws Exception {
   ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry();
   ConnectionFactory<TestApi2> connectionFactory =
       new StubOAuth2ConnectionFactory("clientId", "clientSecret", THROW_EXCEPTION);
   connectionFactoryLocator.addConnectionFactory(connectionFactory);
   StubConnectionRepository connectionRepository = new StubConnectionRepository();
   connectionRepository.addConnection(
       connectionFactory.createConnection(
           new ConnectionData(
               "oauth2Provider", "provider1User1", null, null, null, null, null, null, null)));
   connectionRepository.addConnection(
       connectionFactory.createConnection(
           new ConnectionData(
               "oauth2Provider", "provider1User2", null, null, null, null, null, null, null)));
   assertEquals(2, connectionRepository.findConnections("oauth2Provider").size());
   ConnectController connectController =
       new ConnectController(connectionFactoryLocator, connectionRepository);
   List<DisconnectInterceptor<?>> interceptors = getDisconnectInterceptor();
   connectController.setDisconnectInterceptors(interceptors);
   MockMvc mockMvc = standaloneSetup(connectController).build();
   mockMvc
       .perform(delete("/connect/oauth2Provider/provider1User1"))
       .andExpect(redirectedUrl("/connect/oauth2Provider"));
   assertEquals(1, connectionRepository.findConnections("oauth2Provider").size());
   assertFalse(((TestConnectInterceptor<?>) (interceptors.get(0))).preDisconnectInvoked);
   assertFalse(((TestConnectInterceptor<?>) (interceptors.get(0))).postDisconnectInvoked);
   assertNull(((TestConnectInterceptor<?>) (interceptors.get(0))).connectionFactory);
   assertTrue(((TestConnectInterceptor<?>) (interceptors.get(1))).preDisconnectInvoked);
   assertTrue(((TestConnectInterceptor<?>) (interceptors.get(1))).postDisconnectInvoked);
   assertSame(
       connectionFactory, ((TestConnectInterceptor<?>) (interceptors.get(1))).connectionFactory);
 }
  @Test
  public final void testTotalBoxedLongBoxedLongBoxedLong() {
    final Long[] numbers1 = convertToBoxed(NUMBERS1);
    final Long[] numbers2 = convertToBoxed(NUMBERS2);

    for (final Long n1 : numbers1) {
      for (final Long n2 : numbers2) {
        for (final Long n3 : numbers1) {
          @SuppressWarnings("boxing")
          final long expected = n1 + n2 + n3;
          final long actual = total(n1, n2, n3);
          // System.out.println("expected: " + expected + "\nactual:   " + actual);
          assertTrue(expected == actual);
        }
      }
    }

    final Long[] numbers3 = convertToBoxed(NUMBERS3);
    final Long[] numbers4 = convertToBoxed(NUMBERS4);

    for (final Long n1 : numbers3) {
      for (final Long n2 : numbers4) {
        for (final Long n3 : numbers3) {
          @SuppressWarnings("boxing")
          final long expected = n1 + n2 + n3;
          final long actual = total(n1, n2, n3);
          // System.out.println("expected: " + expected + "\nactual:   " + actual);
          assertTrue(expected == actual);
        }
      }
    }
  }
  @Test
  public final void testSumLongLong() {
    final long[] numbers1 = NUMBERS1;
    final long[] numbers2 = NUMBERS2;

    for (final long n1 : numbers1) {
      for (final long n2 : numbers2) {
        final long expected = n1 + n2;
        final long actual = sum(n1, n2);
        // System.out.println("expected: " + expected + "\nactual:   " + actual);
        assertTrue(expected == actual);
      }
    }

    final long[] numbers3 = NUMBERS3;
    final long[] numbers4 = NUMBERS4;

    for (final long n1 : numbers3) {
      for (final long n2 : numbers4) {
        final long expected = n1 + n2;
        final long actual = sum(n1, n2);
        // System.out.println("expected: " + expected + "\nactual:   " + actual);
        assertTrue(expected == actual);
      }
    }
  }
  @Test
  public void supportsPosixlyCorrectBehavior() {
    OptionParser parser = new OptionParser("i:j::k");
    String[] arguments = {
      "-ibar", "-i", "junk", "xyz", "-jixnay", "foo", "-k", "blah", "--", "bah"
    };

    OptionSet options = parser.parse(arguments);

    assertTrue(options.has("i"));
    assertTrue(options.has("j"));
    assertTrue(options.has("k"));
    assertEquals(asList("bar", "junk"), options.valuesOf("i"));
    assertEquals(singletonList("ixnay"), options.valuesOf("j"));
    assertEquals(asList("xyz", "foo", "blah", "bah"), options.nonOptionArguments());

    parser.posixlyCorrect(true);
    options = parser.parse(arguments);

    assertTrue(options.has("i"));
    assertFalse(options.has("j"));
    assertFalse(options.has("k"));
    assertEquals(asList("bar", "junk"), options.valuesOf("i"));
    assertEquals(emptyList(), options.valuesOf("j"));
    assertEquals(
        asList("xyz", "-jixnay", "foo", "-k", "blah", "--", "bah"), options.nonOptionArguments());
  }
 @Test
 public void one() {
   final List<String> values = asList("a", "b", "a", "c", "a", "d", "e");
   assertTrue(Algorithms.one(values, Conditions.eq("c")));
   assertTrue(Algorithms.one(values, Conditions.eq("a")));
   assertTrue(Algorithms.one(values, Conditions.eq("e")));
   assertFalse(Algorithms.one(values, Conditions.eq("f")));
 }
 @Test
 public void isAnnotatedOnClassWithMetaDepth2() {
   assertTrue(isAnnotated(ComposedTransactionalComponentClass.class, TX_NAME));
   assertTrue(isAnnotated(ComposedTransactionalComponentClass.class, Component.class.getName()));
   assertTrue(
       isAnnotated(
           ComposedTransactionalComponentClass.class,
           ComposedTransactionalComponent.class.getName()));
 }
 private static void delete(File directory) {
   for (File file : directory.listFiles()) {
     if (file.isDirectory()) {
       delete(file);
     } else {
       assertTrue(file.delete());
     }
   }
   assertTrue(directory.delete());
 }
  @Test
  public void all() {
    final List<String> values = asList("a", "b", "a", "c", "a", "d", "e");
    assertTrue(Algorithms.all(values, Conditions.gte("a")));
    assertTrue(Algorithms.all(values, Conditions.lt("z")));
    assertTrue(Algorithms.all(values, Conditions.lte("e")));

    assertFalse(Algorithms.all(values, Conditions.gt("b")));
    assertFalse(Algorithms.all(values, Conditions.eq("a")));
    assertFalse(Algorithms.all(values, Conditions.eq("f")));
  }
 @Test
 public void hasMetaAnnotationTypesOnClassWithMetaDepth2() {
   assertTrue(hasMetaAnnotationTypes(ComposedTransactionalComponentClass.class, TX_NAME));
   assertTrue(
       hasMetaAnnotationTypes(
           ComposedTransactionalComponentClass.class, Component.class.getName()));
   assertFalse(
       hasMetaAnnotationTypes(
           ComposedTransactionalComponentClass.class,
           ComposedTransactionalComponent.class.getName()));
 }
 @Test
 public void getMergedAnnotationAttributesFavorsLocalComposedAnnotationOverInheritedAnnotation() {
   Class<?> element = SubClassWithInheritedAnnotation.class;
   String name = TX_NAME;
   AnnotationAttributes attributes = getMergedAnnotationAttributes(element, name);
   assertNotNull(
       "AnnotationAttributes for @Transactional on SubClassWithInheritedAnnotation", attributes);
   // Verify contracts between utility methods:
   assertTrue(isAnnotated(element, name));
   assertTrue(
       "readOnly flag for SubClassWithInheritedAnnotation.", attributes.getBoolean("readOnly"));
 }
 @Test
 public void connect_OAuth1Provider() throws Exception {
   ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry();
   ConnectionFactory<TestApi1> connectionFactory =
       new StubOAuth1ConnectionFactory("clientId", "clientSecret");
   connectionFactoryLocator.addConnectionFactory(connectionFactory);
   ConnectController connectController = new ConnectController(connectionFactoryLocator, null);
   List<ConnectInterceptor<?>> interceptors = getConnectInterceptor();
   connectController.setConnectInterceptors(interceptors);
   connectController.afterPropertiesSet();
   MockMvc mockMvc = standaloneSetup(connectController).build();
   mockMvc
       .perform(post("/connect/oauth1Provider"))
       .andExpect(
           redirectedUrl("https://someprovider.com/oauth/authorize?oauth_token=requestToken"))
       .andExpect(
           request()
               .sessionAttribute(
                   "oauthToken",
                   samePropertyValuesAs(new OAuthToken("requestToken", "requestTokenSecret"))));
   // Check for preConnect() only. The postConnect() won't be invoked until after callback
   TestConnectInterceptor<?> textInterceptor1 = (TestConnectInterceptor<?>) (interceptors.get(0));
   assertTrue(textInterceptor1.preConnectInvoked);
   assertEquals("oauth1Provider", textInterceptor1.connectionFactory.getProviderId());
   assertFalse(((TestConnectInterceptor<?>) (interceptors.get(1))).preConnectInvoked);
 }
 @Test
 public void oauth2Callback() throws Exception {
   ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry();
   ConnectionFactory<TestApi2> connectionFactory =
       new StubOAuth2ConnectionFactory("clientId", "clientSecret");
   connectionFactoryLocator.addConnectionFactory(connectionFactory);
   StubConnectionRepository connectionRepository = new StubConnectionRepository();
   ConnectController connectController =
       new ConnectController(connectionFactoryLocator, connectionRepository);
   List<ConnectInterceptor<?>> interceptors = getConnectInterceptor();
   connectController.setConnectInterceptors(interceptors);
   connectController.afterPropertiesSet();
   MockMvc mockMvc = standaloneSetup(connectController).build();
   assertEquals(0, connectionRepository.findConnections("oauth2Provider").size());
   mockMvc
       .perform(get("/connect/oauth2Provider").param("code", "oauth2Code"))
       .andExpect(redirectedUrl("/connect/oauth2Provider"));
   List<Connection<?>> connections = connectionRepository.findConnections("oauth2Provider");
   assertEquals(1, connections.size());
   assertEquals("oauth2Provider", connections.get(0).getKey().getProviderId());
   // Check for postConnect() only. The preConnect() is only invoked during the initial portion of
   // the flow
   assertFalse(((TestConnectInterceptor<?>) (interceptors.get(0))).postConnectInvoked);
   TestConnectInterceptor<?> testInterceptor2 = (TestConnectInterceptor<?>) (interceptors.get(1));
   assertTrue(testInterceptor2.postConnectInvoked);
 }
  @Test
  public void supportsOptionSynonyms() {
    OptionParser parser = new OptionParser();
    List<String> synonyms = asList("message", "blurb", "greeting");
    parser.acceptsAll(synonyms).withRequiredArg();
    String expectedMessage = "Hello";

    OptionSet options = parser.parse("--message", expectedMessage);

    for (String each : synonyms) {
      assertTrue(each, options.has(each));
      assertTrue(each, options.hasArgument(each));
      assertEquals(each, expectedMessage, options.valueOf(each));
      assertEquals(each, asList(expectedMessage), options.valuesOf(each));
    }
  }
Example #14
0
  @Test
  public void serviceBCalledExactlyOnce() {
    new MockServiceBForOneInvocation();

    boolean result = new ServiceA().doSomethingThatUsesServiceB(2, "test");

    assertTrue(result);
  }
 @Test
 public void getMergedAnnotationAttributesOnNonInheritedAnnotationInterface() {
   Class<?> element = NonInheritedAnnotationInterface.class;
   String name = Order.class.getName();
   AnnotationAttributes attributes = getMergedAnnotationAttributes(element, name);
   assertNotNull("Should find @Order on NonInheritedAnnotationInterface", attributes);
   // Verify contracts between utility methods:
   assertTrue(isAnnotated(element, name));
 }
 @Test
 public void getMergedAnnotationAttributesOnInheritedAnnotationInterface() {
   Class<?> element = InheritedAnnotationInterface.class;
   String name = TX_NAME;
   AnnotationAttributes attributes = getMergedAnnotationAttributes(element, name);
   assertNotNull("Should find @Transactional on InheritedAnnotationInterface", attributes);
   // Verify contracts between utility methods:
   assertTrue(isAnnotated(element, name));
 }
 private void assertParses(
     String name, Predicate<CommandLineOptions> property, String... argLines) {
   stream(argLines)
       .forEach(
           argLine -> {
             CommandLineOptions options = parseArgLine(argLine);
             assertTrue(property.test(options), () -> name + " should be enabled by: " + argLine);
           });
 }
 @Test
 public void getMergedAnnotationAttributesOnClassWithLocalAnnotation() {
   Class<?> element = TxConfig.class;
   String name = TX_NAME;
   AnnotationAttributes attributes = getMergedAnnotationAttributes(element, name);
   assertNotNull("Annotation attributes for @Transactional on TxConfig", attributes);
   assertEquals("value for TxConfig.", "TxConfig", attributes.getString("value"));
   // Verify contracts between utility methods:
   assertTrue(isAnnotated(element, name));
 }
  private void assertGetMergedAnnotation(Class<?> element, String... expected) {
    String name = ContextConfig.class.getName();
    ContextConfig contextConfig = getMergedAnnotation(element, ContextConfig.class);

    assertNotNull("Should find @ContextConfig on " + element.getSimpleName(), contextConfig);
    assertArrayEquals("locations", expected, contextConfig.locations());
    assertArrayEquals("value", expected, contextConfig.value());
    assertArrayEquals("classes", new Class<?>[0], contextConfig.classes());

    // Verify contracts between utility methods:
    assertTrue(isAnnotated(element, name));
  }
Example #20
0
 /** Validate that the client can intentionally disconnect and reconnect */
 @Test
 public void testClientDisconnect() throws Exception {
   String connectionId = blockingSSLConnect();
   selector.disconnect(connectionId);
   selector.poll(10, asList(SelectorTest.createSend(connectionId, "hello1")));
   assertEquals("Request should not have succeeded", 0, selector.completedSends().size());
   assertEquals("There should be a disconnect", 1, selector.disconnected().size());
   assertTrue(
       "The disconnect should be from our node", selector.disconnected().contains(connectionId));
   connectionId = blockingSSLConnect();
   assertEquals("hello2", blockingRequest(connectionId, "hello2"));
 }
  @Test
  public final void testTotalIterableOfLong() {
    final Iterable<Long> numbers1 = asList(convertToBoxed(NUMBERS1));
    final Iterable<Long> numbers2 = asList(convertToBoxed(NUMBERS2));

    long total1 = 0;
    for (final Long n : numbers1) total1 += n.longValue();

    long total2 = 0;
    for (final Long n : numbers2) total2 += n.longValue();

    final long expected1 = total1;
    final long actual1 = total(numbers1);
    // System.out.println("expected: " + expected1 + "\nactual:   " + actual1);
    assertTrue(expected1 == actual1);
    final long expected2 = total2;
    final long actual2 = total(numbers2);
    // System.out.println("expected: " + expected2 + "\nactual:   " + actual2);
    assertTrue(expected2 == actual2);

    final Iterable<Long> numbers3 = asList(convertToBoxed(NUMBERS3));
    final Iterable<Long> numbers4 = asList(convertToBoxed(NUMBERS4));

    long total3 = 0;
    for (final Long n : numbers3) total3 += n.longValue();

    long total4 = 0;
    for (final Long n : numbers4) total4 += n.longValue();

    final long expected3 = total3;
    final long actual3 = total(numbers3);
    // System.out.println("expected: " + expected3 + "\nactual:   " + actual3);
    assertTrue(expected3 == actual3);

    final long expected4 = total4;
    final long actual4 = total(numbers4);
    // System.out.println("expected: " + expected4 + "\nactual:   " + actual4);
    assertTrue(expected4 == actual4);
  }
  @Test
  public void getMergedAnnotationAttributesWithAliasedValueComposedAnnotation() {
    Class<?> element = AliasedValueComposedContextConfigClass.class;
    String name = ContextConfig.class.getName();
    AnnotationAttributes attributes = getMergedAnnotationAttributes(element, name);

    assertNotNull("Should find @ContextConfig on " + element.getSimpleName(), attributes);
    assertArrayEquals("locations", asArray("test.xml"), attributes.getStringArray("locations"));
    assertArrayEquals("value", asArray("test.xml"), attributes.getStringArray("value"));

    // Verify contracts between utility methods:
    assertTrue(isAnnotated(element, name));
  }
  @Test
  public final void testSumLongArray() {
    final long[] numbers1 = NUMBERS1;
    final long[] numbers2 = NUMBERS2;

    long total1 = 0;
    for (final long n : numbers1) total1 += n;

    long total2 = 0;
    for (final long n : numbers2) total2 += n;

    final long expected1 = total1;
    final long actual1 = sum(numbers1);
    // System.out.println("expected: " + expected1 + "\nactual:   " + actual1);
    assertTrue(expected1 == actual1);
    final long expected2 = total2;
    final long actual2 = sum(numbers2);
    // System.out.println("expected: " + expected2 + "\nactual:   " + actual2);
    assertTrue(expected2 == actual2);

    final long[] numbers3 = NUMBERS3;
    final long[] numbers4 = NUMBERS4;

    long total3 = 0;
    for (final long n : numbers3) total3 += n;

    long total4 = 0;
    for (final long n : numbers4) total4 += n;

    final long expected3 = total3;
    final long actual3 = sum(numbers3);
    // System.out.println("expected: " + expected3 + "\nactual:   " + actual3);
    assertTrue(expected3 == actual3);

    final long expected4 = total4;
    final long actual4 = sum(numbers4);
    // System.out.println("expected: " + expected4 + "\nactual:   " + actual4);
    assertTrue(expected4 == actual4);
  }
  @Test
  public void shouldIgnoreTestsInDependentProjects() {
    List<File> outputDirs = asList(new File("target/classes"));
    List<File> classDirsInClasspath = fakeBuildPaths();
    String rawClasspath = fakeClasspath().getCompleteClasspath();
    StandaloneClasspath classpath =
        new StandaloneClasspath(outputDirs, classDirsInClasspath, rawClasspath);

    ClassFileTestDetector testDetector = new ClassFileTestDetector(mock(TestFilter.class));
    testDetector.setClasspathProvider(classpath);
    File classFileNotInOutputDirectory = getFileForClass(TestFakeProduct.class);
    assertTrue(testDetector.findTestsToRun(asList(classFileNotInOutputDirectory)).isEmpty());
  }
  @Test
  public final void testTotalIterableOfT() {
    final Iterable<ValueContainer<Long>> numbers1 = asList(VALUE_CONTAINERS);

    long total1 = 0;
    for (final ValueContainer<Long> n : numbers1) total1 += n.getValue();

    final long expected1 = total1;
    final long actual1 =
        total(
            numbers1,
            new Function1<ValueContainer<Long>, Long>() {
              @Override
              public Long apply(final ValueContainer<Long> input) {
                return input.getValue();
              }
            });
    // System.out.println("expected: " + expected1 + "\nactual:   " + actual1);
    assertTrue(expected1 == actual1);

    final Iterable<ValueContainer<Long>> numbers2 = asList(RANDOM_VALUE_CONTAINERS);

    long total2 = 0;
    for (final ValueContainer<Long> n : numbers2) total2 += n.getValue();

    final long expected2 = total2;
    final long actual2 =
        total(
            numbers2,
            new Function1<ValueContainer<Long>, Long>() {
              @Override
              public Long apply(final ValueContainer<Long> input) {
                return input.getValue();
              }
            });
    // System.out.println("expected: " + expected3 + "\nactual:   " + actual3);
    assertTrue(expected2 == actual2);
  }
  /**
   * Bridge/bridged method setup code copied from {@link
   * org.springframework.core.BridgeMethodResolverTests#testWithGenericParameter()}.
   *
   * @since 4.2
   */
  @Test
  public void findMergedAnnotationAttributesFromBridgeMethod() throws NoSuchMethodException {
    Method[] methods = StringGenericParameter.class.getMethods();
    Method bridgeMethod = null;
    Method bridgedMethod = null;

    for (Method method : methods) {
      if ("getFor".equals(method.getName())
          && !method.getParameterTypes()[0].equals(Integer.class)) {
        if (method.getReturnType().equals(Object.class)) {
          bridgeMethod = method;
        } else {
          bridgedMethod = method;
        }
      }
    }
    assertTrue(bridgeMethod != null && bridgeMethod.isBridge());
    assertTrue(bridgedMethod != null && !bridgedMethod.isBridge());

    AnnotationAttributes attributes = findMergedAnnotationAttributes(bridgeMethod, Order.class);
    assertNotNull(
        "Should find @Order on StringGenericParameter.getFor() bridge method", attributes);
  }
Example #27
0
  /**
   * Send multiple requests to several connections in parallel. Validate that responses are received
   * in the order that requests were sent.
   */
  @Test
  public void testNormalOperation() throws Exception {
    int conns = 5;

    // create connections
    ArrayList<String> connectionIds = new ArrayList<String>();
    for (int i = 0; i < conns; i++) {
      connectionIds.add(blockingSSLConnect());
    }

    // send echo requests and receive responses
    int responseCount = 0;
    List<NetworkSend> sends = new ArrayList<NetworkSend>();
    for (int i = 0; i < conns; i++) {
      String connectionId = connectionIds.get(i);
      sends.add(SelectorTest.createSend(connectionId, connectionId + "&" + 0));
    }

    // loop until we complete all requests
    while (responseCount < conns) {
      // do the i/o
      selector.poll(0L, sends);

      assertEquals("No disconnects should have occurred.", 0, selector.disconnected().size());

      // handle any responses we may have gotten
      for (NetworkReceive receive : selector.completedReceives()) {
        String[] pieces = SelectorTest.asString(receive).split("&");
        assertEquals("Should be in the form 'conn-counter'", 2, pieces.length);
        assertEquals("Check the source", receive.getConnectionId(), pieces[0]);
        assertEquals(
            "Check that the receive has kindly been rewound",
            0,
            receive.getReceivedBytes().getPayload().position());
        assertTrue(
            "Received connectionId is as expected ",
            connectionIds.contains(receive.getConnectionId()));
        assertEquals("Check the request counter", 0, Integer.parseInt(pieces[1]));
        responseCount++;
      }

      // prepare new sends for the next round
      sends.clear();
      for (NetworkSend send : selector.completedSends()) {
        String dest = send.getConnectionId();
        sends.add(SelectorTest.createSend(dest, dest + "&" + 0));
      }
    }
  }
Example #28
0
  private void assertEchoed(final String stringMessage, final String bytesMessage)
      throws InterruptedException, ExecutionException {
    final CountDownLatch latch = new CountDownLatch(3);
    final List<String> received = new ArrayList<String>();
    WebSocket ws =
        new WebSocketClient(
            URI.create("ws://0.0.0.0:8080"),
            new WebSocketHandler() {
              @Override
              public void onOpen(WebSocketConnection connection) throws Throwable {}

              @Override
              public void onClose(WebSocketConnection connection) throws Throwable {}

              @Override
              public void onMessage(WebSocketConnection connection, String msg) throws Throwable {
                received.add(msg);

                if (!msg.equals(stringMessage)) {
                  // It's the initial message from echo.rb
                  connection.send(stringMessage);
                } else {
                  // It's our own message coming back
                  connection.send(bytesMessage.getBytes("UTF-8"));
                }
                latch.countDown();
              }

              @Override
              public void onMessage(WebSocketConnection connection, byte[] msg) throws Throwable {
                received.add(new String(msg, "UTF-8"));
                latch.countDown();
              }

              @Override
              public void onPing(WebSocketConnection connection, byte[] msg) throws Throwable {
                connection.pong(msg);
              }

              @Override
              public void onPong(WebSocketConnection connection, byte[] msg) throws Throwable {}
            });
    ws.start().get();
    boolean finished = latch.await(500, TimeUnit.MILLISECONDS);
    assertEquals(asList("Hello Client!", stringMessage, bytesMessage), received);
    assertTrue(finished);
  }
 @Test
 public void connect_OAuth2Provider() throws Exception {
   ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry();
   ConnectionFactory<TestApi2> connectionFactory =
       new StubOAuth2ConnectionFactory("clientId", "clientSecret");
   connectionFactoryLocator.addConnectionFactory(connectionFactory);
   ConnectController connectController = new ConnectController(connectionFactoryLocator, null);
   List<ConnectInterceptor<?>> interceptors = getConnectInterceptor();
   connectController.setConnectInterceptors(interceptors);
   MockMvc mockMvc = standaloneSetup(connectController).build();
   mockMvc.perform(post("/connect/oauth2Provider")).andExpect(redirectedUrl(OAUTH2_AUTHORIZE_URL));
   // Check for preConnect() only. The postConnect() won't be invoked until after callback
   assertFalse(((TestConnectInterceptor<?>) (interceptors.get(0))).preConnectInvoked);
   TestConnectInterceptor<?> testInterceptor2 = (TestConnectInterceptor<?>) (interceptors.get(1));
   assertTrue(testInterceptor2.preConnectInvoked);
   assertEquals("oauth2Provider", testInterceptor2.connectionFactory.getProviderId());
 }
  @Test
  public void getMergedAnnotationWithImplicitAliasesInMetaAnnotationOnComposedAnnotation() {
    Class<?> element = ComposedImplicitAliasesContextConfigClass.class;
    String name = ImplicitAliasesContextConfig.class.getName();
    ImplicitAliasesContextConfig config =
        getMergedAnnotation(element, ImplicitAliasesContextConfig.class);
    String[] expected = asArray("A.xml", "B.xml");

    assertNotNull(
        "Should find @ImplicitAliasesContextConfig on " + element.getSimpleName(), config);
    assertArrayEquals("groovyScripts", expected, config.groovyScripts());
    assertArrayEquals("xmlFiles", expected, config.xmlFiles());
    assertArrayEquals("locations", expected, config.locations());
    assertArrayEquals("value", expected, config.value());

    // Verify contracts between utility methods:
    assertTrue(isAnnotated(element, name));
  }