我无法使用SimpMessagingTemplate将消息示例发送到单元测试中以将消息发送到端点.
我按照这里的说明操作:https: //spring.io/guides/gs/messaging-stomp-websocket/
到目前为止我的Controller看起来像:
@Data @NoArgsConstructor @AllArgsConstructor
public static class Message {
private Long id;
private String value;
private long time;
}
@MessageMapping("/message")
@SendTo("/topic/response")
public Message slowEndpont(Message message) throws Exception {
Thread.sleep(3000); // simulated delay
System.err.println("Message Received: " + message);
return new Message(message.id, "Hello Client", System.currentTimeMillis());
}
Run Code Online (Sandbox Code Playgroud)
我的单元测试现在尝试发送消息:
@Autowired
SimpMessagingTemplate messageTemplate;
@Test
public void sendMessage() throws Exception {
System.err.println("** Sending messages...");
messageTemplate.convertAndSend("/app/message",
new MessageController.Message(1L, "Hello Server", System.currentTimeMillis()));
messageTemplate.convertAndSend("/topic/message",
new MessageController.Message(1L, "Hello Server", System.currentTimeMillis()));
messageTemplate.convertAndSend("/queue/message",
new MessageController.Message(1L, "Hello Server", …Run Code Online (Sandbox Code Playgroud) 任何人都知道为什么在Android中新生成的选项卡式活动中底部是否在屏幕外?
ViewPager对于整个屏幕来说太长了
<android.support.v4.view.ViewPager
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
Run Code Online (Sandbox Code Playgroud)
如果您将它们对齐到屏幕底部,则55dp中的子片段中的所有视图都不在屏幕上.
谢谢,
保罗
PS:生成代码的完整XML:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.comfylight.bulbtest.FooBar">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/appbar_padding_top"
android:theme="@style/AppTheme.NoActionBar.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/AppTheme.NoActionBar.PopupOverlay">
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_dialog_email" />
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud) java android android-viewpager android-coordinatorlayout android-tablayout