小编Law*_*ing的帖子

How can I initialize variable before each test using kotlin-test framework

I'm trying to find a way to set up variable before each test. Just like the @Before method in Junit. Go through the doc from kotlin-test, I found that I can use interceptTestCase() interface. But unfortunately, the code below will trigger exception:

kotlin.UninitializedPropertyAccessException: lateinit property text has not been initialized

class KotlinTest: StringSpec() {
lateinit var text:String
init {
    "I hope variable is be initialized before each test" {
        text shouldEqual "ABC"
    }

    "I hope variable is be initialized before …
Run Code Online (Sandbox Code Playgroud)

kotlin kotlintest

5
推荐指数
1
解决办法
1538
查看次数

如何在不禁用 firewalld (Kubernetes) 的情况下使用 Flannel

我是法兰绒和 K8s 的新手。我在我的 1 个主节点和 2 个节点集群(从 KVM 创建)上玩弄它们。

我用法兰绒网络插件初始化了我的集群。然后我发现我无法到达内部。结果证明我的网络或 DNS 进程可能有问题。

https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/之后,我将8285 和 8472添加到 firewalld

[root@k8smaster ~]# firewall-cmd --list-port
6443/tcp 80/tcp 8285/udp 8472/udp 8472/tcp 8285/tcp
Run Code Online (Sandbox Code Playgroud)

我得到了

[root@k8smaster ~]# kubectl exec -ti dnsutils -- nslookup kubernetes.default
;; connection timed out; no servers could be reached

command terminated with exit code 1
Run Code Online (Sandbox Code Playgroud)

但是,如果我停止firewalld,一切都很好。

[root@k8smaster ~]# kubectl exec -ti dnsutils -- nslookup kubernetes.default
Server:     10.96.0.10
Address:    10.96.0.10#53

Name:   kubernetes.default.svc.cluster.local
Address: 10.96.0.1
Run Code Online (Sandbox Code Playgroud)

所以我的问题是,我应该将任何端口添加到 firewalld 中吗?如果有任何信息,请告诉我。我应该在这里补充。谢谢你。

kubernetes flannel

4
推荐指数
2
解决办法
3466
查看次数

Clojure的功能#(:jerry @%)意味着什么

我是Clojure的新人.我在Clojure Koans的帮助下学习.我找到了以下代码的答案:

(= ["Real Jerry" "Bizarro Jerry"]
       (do
         (dosync
          (ref-set the-world {})
          (alter the-world assoc :jerry "Real Jerry")
          (alter bizarro-world assoc :jerry "Bizarro Jerry")
          (vec (map #(:jerry @%) [the-world bizarro-world]))))))
Run Code Online (Sandbox Code Playgroud)

来自:https://github.com/viebel/clojure-koans/blob/master/src/koans/16_refs.clj#L42

谷歌搜索"Clojure @%"是非常不友好的.所以我从互联网上得不到什么.

它如何用于"#(:jerry @%)"功能?

以下代码是我的答案,但它不起作用.

(= ["Real Jerry" "Bizarro Jerry"]
       (do
         (dosync
          (ref-set the-world {})
          (alter the-world assoc :jerry "Real Jerry")
          (alter bizarro-world assoc :jerry "Bizarro Jerry")
          (vec (map (fn [x] (:jerry x)) [the-world bizarro-world]))
         )))
Run Code Online (Sandbox Code Playgroud)

clojure

3
推荐指数
1
解决办法
325
查看次数

Android:FargmentTabHost - 找不到ID为xxx的标签内容FrameLayout

我陷入了"No tab content FrameLayout found in XXX"错误.请帮忙.

我的代码如下:

主要活动

package com.example.demo;

import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTabHost;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;

import com.example.demo.fragments.StateFragment;


public class MainActivity extends AppCompatActivity {
    private FragmentTabHost mTabHost;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        setSupportActionBar((Toolbar) findViewById(R.id.toolBar));
        initTabHost();
    }


    private void initTabHost(){
        mTabHost = (FragmentTabHost)findViewById(android.R.id.tabhost);
        mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);
        mTabHost.addTab(mTabHost.newTabSpec("simple").setIndicator("Simple"),
                StateFragment.class, null);
    }
}
Run Code Online (Sandbox Code Playgroud)

activity_main.xml中

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:minHeight="?attr/actionBarSize"
        android:background="?attr/colorPrimary">

        <TextView …
Run Code Online (Sandbox Code Playgroud)

android fragment-tab-host

2
推荐指数
1
解决办法
2617
查看次数