package com.yihu.hos.broker.services.camel;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;

import java.io.File;
import java.net.URI;

/**
 * @author Airhead
 * @since 2016/12/6.
 */
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
@WebAppConfiguration
public class ESBCamelServiceTest {
    @Autowired
    private ESBCamelService esbCamelService;
    @Test
    public void onServiceFlowAdd() throws Exception {
    String msg="{\n" +
            "    \"routeCode\" : \"invokeSync\",\n" +
            "    \"updated\" : null,\n" +
            "    \"flowType\" : \"class\",\n" +
            "    \"handleFiles\" : [ \n" +
            "        {\n" +
            "            \"usage\" : \"processor\",\n" +
            "            \"packageName\" : \"apisync.processor\",\n" +
            "            \"className\" : \"ApiProcessor\",\n" +
            "            \"filePath\" : \"22241906357fac850e39df5dd74e7ddc4f1c6808019c571a98e96ad7e01a635afe687822969a785b523d97cbc5d33904b5296227c61c08bb\",\n" +
            "            \"fileType\" : \"class\",\n" +
            "            \"routeCode\" : \"invokeSync\"\n" +
            "        }, \n" +
            "        {\n" +
            "            \"usage\" : \"route\",\n" +
            "            \"packageName\" : \"apisync.route\",\n" +
            "            \"className\" : \"ApiRouteBulider\",\n" +
            "            \"filePath\" : \"89108d6cbec5e48ae19806476e1e946fb10e5656424326c288c69dcfda6a3add873b0c64959cb310e96e4cd4f3c0d627f82f813633c2f8ebe73a3fa3a83feb15\",\n" +
            "            \"fileType\" : \"class\",\n" +
            "            \"routeCode\" : \"invokeSync\"\n" +
            "        }\n" +
            "    ]\n" +
            "}";

    esbCamelService.onServiceFlowAdd(msg);

    }

    @Test
    public void onServiceFlowModifyAdd() throws Exception {

    }

    @Test
    public void onServiceFlowModifyReduce() throws Exception {

    }

    @Test
    public void onServiceFlowDelete() throws Exception {

    }

    @Test
    public void onServiceFlowStart() throws Exception {

    }

    @Test
    public void onServiceFlowStop() throws Exception {

    }

    @Test
    public void onProcessorAdded() throws Exception {
        String url = this.getClass().getProtectionDomain().getClassLoader().getResource("").toString();
        System.out.println(url);

        File systemClassFlowPath = new File(this.getClass().getProtectionDomain().getClassLoader().getResource("").getPath());

        String sysPath = systemClassFlowPath.toURI().toURL().toString();
        System.out.println(sysPath);
        URI uri = ESBCamelService.class.getResource("").toURI();
        File file  = new File("d:/usr");
        URI uri1 = file.toURI();
        uri1.toURL();


    }

}