.
This commit is contained in:
parent
1db6a3ae7b
commit
d6e3450e2b
|
@ -4,6 +4,14 @@ package com.loafle.bridge.discoveryport.constant;
|
||||||
* Created by root on 16. 11. 15.
|
* Created by root on 16. 11. 15.
|
||||||
*/
|
*/
|
||||||
public enum DirectionType {
|
public enum DirectionType {
|
||||||
S, // Send
|
Send("S"),
|
||||||
R // Recv
|
Recv("R");
|
||||||
|
|
||||||
|
private String stringValue;
|
||||||
|
DirectionType(String string) {stringValue = string;}
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return stringValue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,5 +5,14 @@ package com.loafle.bridge.discoveryport.constant;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public enum PortType {
|
public enum PortType {
|
||||||
TCP,UDP
|
TCP("TCP"),
|
||||||
|
UDP("UDP");
|
||||||
|
|
||||||
|
private String stringValue;
|
||||||
|
PortType(String string) {stringValue = string;}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return stringValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,25 @@
|
||||||
package com.loafle.bridge.discoveryport.controller;
|
package com.loafle.bridge.discoveryport.controller;
|
||||||
|
|
||||||
|
import com.loafle.bridge.discoveryport.entity.DiscoveryPort;
|
||||||
|
import com.loafle.bridge.discoveryport.repository.DiscoveryPortRepository;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by root on 16. 11. 15.
|
* Created by root on 16. 11. 15.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@RestController
|
||||||
public class DiscoveryPortController {
|
public class DiscoveryPortController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
DiscoveryPortRepository repository;
|
||||||
|
|
||||||
|
@RequestMapping(value = "/discoveryPort/{id}", method = RequestMethod.GET)
|
||||||
|
public DiscoveryPort get(@PathVariable(value = "id") long id) {
|
||||||
|
return repository.findOne(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.loafle.bridge.discoveryport.entity;
|
package com.loafle.bridge.discoveryport.entity;
|
||||||
|
|
||||||
import com.loafle.bridge.discoveryhost.entity.DiscoveryHost;
|
|
||||||
import com.loafle.bridge.discoveryport.constant.PortType;
|
import com.loafle.bridge.discoveryport.constant.PortType;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
|
@ -15,13 +14,13 @@ public class DiscoveryPort {
|
||||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
private long id;
|
private long id;
|
||||||
|
|
||||||
@ManyToOne
|
// @ManyToOne
|
||||||
@JoinColumn(name = "HOST_ID", nullable = false)
|
// @JoinColumn(name = "HOST_ID", nullable = false)
|
||||||
private DiscoveryHost host;
|
// private DiscoveryHost host;
|
||||||
|
|
||||||
@Column(name = "PORT_TYPE",nullable = false)
|
@Column(name = "PORT_TYPE",nullable = false)
|
||||||
@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
private PortType type;
|
private PortType portType;
|
||||||
|
|
||||||
@Column(name = "PORT_NUMBER",nullable = false)
|
@Column(name = "PORT_NUMBER",nullable = false)
|
||||||
private short portNumber;
|
private short portNumber;
|
||||||
|
@ -29,32 +28,18 @@ public class DiscoveryPort {
|
||||||
@OneToMany(mappedBy = "port" , fetch = FetchType.LAZY)
|
@OneToMany(mappedBy = "port" , fetch = FetchType.LAZY)
|
||||||
private List<ServiceScanHistory> histories;
|
private List<ServiceScanHistory> histories;
|
||||||
|
|
||||||
@Column(name = "CREATE_AT",nullable = false,updatable = false)
|
@Column(name = "CREATE_DATE", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", nullable = false, insertable = false, updatable = false)
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
private Date createDate;
|
||||||
private Date createAt;
|
|
||||||
|
|
||||||
@Column(name = "UPDATE_AT",nullable = false)
|
@Column(name = "UPDATE_DATE", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", nullable = false, insertable = false)
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
private Date updateDate;
|
||||||
private Date updateAt;
|
|
||||||
|
|
||||||
|
|
||||||
public DiscoveryPort() {}
|
public DiscoveryPort() {}
|
||||||
|
|
||||||
public DiscoveryHost getHost() {
|
public DiscoveryPort(PortType type, short portNumber) {
|
||||||
return host;
|
this.portType = type;
|
||||||
}
|
this.portNumber = portNumber;
|
||||||
|
|
||||||
public void setHost(DiscoveryHost host) {
|
|
||||||
this.host = host;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DiscoveryPort(PortType type, DiscoveryHost host, short port, Date createAt, Date updateAt) {
|
|
||||||
this.host = host;
|
|
||||||
|
|
||||||
this.type = type;
|
|
||||||
this.portNumber = port;
|
|
||||||
this.createAt = createAt;
|
|
||||||
this.updateAt = updateAt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getId() {
|
public long getId() {
|
||||||
|
@ -65,12 +50,12 @@ public class DiscoveryPort {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PortType getType() {
|
public PortType getPortType() {
|
||||||
return type;
|
return portType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(PortType type) {
|
public void setPortType(PortType portType) {
|
||||||
this.type = type;
|
this.portType = portType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public short getPortNumber() {
|
public short getPortNumber() {
|
||||||
|
@ -81,22 +66,6 @@ public class DiscoveryPort {
|
||||||
this.portNumber = portNumber;
|
this.portNumber = portNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getCreateAt() {
|
|
||||||
return createAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreateAt(Date createAt) {
|
|
||||||
this.createAt = createAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getUpdateAt() {
|
|
||||||
return updateAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUpdateAt(Date updateAt) {
|
|
||||||
this.updateAt = updateAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ServiceScanHistory> getHistories() {
|
public List<ServiceScanHistory> getHistories() {
|
||||||
return histories;
|
return histories;
|
||||||
}
|
}
|
||||||
|
@ -104,4 +73,20 @@ public class DiscoveryPort {
|
||||||
public void setHistories(List<ServiceScanHistory> histories) {
|
public void setHistories(List<ServiceScanHistory> histories) {
|
||||||
this.histories = histories;
|
this.histories = histories;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Date getCreateDate() {
|
||||||
|
return createDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreateDate(Date createDate) {
|
||||||
|
this.createDate = createDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getUpdateDate() {
|
||||||
|
return updateDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdateDate(Date updateDate) {
|
||||||
|
this.updateDate = updateDate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,9 +28,8 @@ public class ServiceScanHistory {
|
||||||
@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
private DirectionType direction;
|
private DirectionType direction;
|
||||||
|
|
||||||
@Column(name = "CREATE_AT",nullable = false,updatable = false)
|
@Column(name = "CREATE_DATE", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", nullable = false, insertable = false, updatable = false)
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
private Date createDate;
|
||||||
private Date createAt;
|
|
||||||
|
|
||||||
@Lob
|
@Lob
|
||||||
@Column(name = "PACKET", nullable = false)
|
@Column(name = "PACKET", nullable = false)
|
||||||
|
@ -43,7 +42,6 @@ public class ServiceScanHistory {
|
||||||
this.serviceName = serviceName;
|
this.serviceName = serviceName;
|
||||||
this.direction = direction;
|
this.direction = direction;
|
||||||
this.packet = packet;
|
this.packet = packet;
|
||||||
this.createAt = createAt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getId() {
|
public long getId() {
|
||||||
|
@ -78,12 +76,12 @@ public class ServiceScanHistory {
|
||||||
this.direction = direction;
|
this.direction = direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getCreateAt() {
|
public Date getCreateDate() {
|
||||||
return createAt;
|
return createDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCreateAt(Date createAt) {
|
public void setCreateDate(Date createDate) {
|
||||||
this.createAt = createAt;
|
this.createDate = createDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getPacket() {
|
public byte[] getPacket() {
|
||||||
|
|
|
@ -1,23 +1,17 @@
|
||||||
package hello;
|
package hello;
|
||||||
|
|
||||||
import hello.entity.Member;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
|
|
||||||
import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by jackdaw on 16. 11. 11.
|
* Created by jackdaw on 16. 11. 11.
|
||||||
*/
|
*/
|
||||||
@Configuration
|
//@Configuration
|
||||||
public class JPAConfiguration extends RepositoryRestMvcConfiguration {
|
//public class JPAConfiguration extends RepositoryRestMvcConfiguration {
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
protected void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
|
// protected void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
|
||||||
config.exposeIdsFor(Member.class);
|
// config.exposeIdsFor(Member.class);
|
||||||
//config.setDefaultMediaType(MediaType.APPLICATION_JSON);
|
// //config.setDefaultMediaType(MediaType.APPLICATION_JSON);
|
||||||
//config.useHalAsDefaultJsonMediaType(false);
|
// //config.useHalAsDefaultJsonMediaType(false);
|
||||||
|
// }
|
||||||
}
|
//}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -39,11 +39,11 @@ public class DiscoveryPortRepositoryTest {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void Before() {
|
public void Before() {
|
||||||
repo.save(new DiscoveryPort(PortType.TCP,null ,(short)1, new Date(), new Date()));
|
repo.save(new DiscoveryPort(PortType.TCP,(short)1));
|
||||||
repo.save(new DiscoveryPort(PortType.UDP,null , (short)2, new Date(), new Date()));
|
repo.save(new DiscoveryPort(PortType.UDP, (short)2));
|
||||||
repo.save(new DiscoveryPort(PortType.TCP,null , (short)3, new Date(), new Date()));
|
repo.save(new DiscoveryPort(PortType.TCP, (short)3));
|
||||||
repo.save(new DiscoveryPort(PortType.UDP,null , (short)4, new Date(), new Date()));
|
repo.save(new DiscoveryPort(PortType.UDP, (short)4));
|
||||||
repo.save(new DiscoveryPort(PortType.TCP,null , (short)5, new Date(), new Date()));
|
repo.save(new DiscoveryPort(PortType.TCP, (short)5));
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
|
@ -52,19 +52,20 @@ public class DiscoveryPortRepositoryTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@Transactional
|
||||||
public void TestInsertPort() {
|
public void TestInsertPort() {
|
||||||
DiscoveryPort p = new DiscoveryPort(PortType.TCP, null ,(short)1, new Date(), new Date());
|
DiscoveryPort p = new DiscoveryPort(PortType.TCP, (short)1);
|
||||||
|
|
||||||
repo.save(p);
|
repo.save(p);
|
||||||
DiscoveryPort compare = repo.findOne(p.getId());
|
DiscoveryPort compare = repo.findOne(p.getId());
|
||||||
|
|
||||||
assertEquals(p.getId(),compare.getId());
|
assertEquals(p.getId(),compare.getId());
|
||||||
|
|
||||||
l.debug(p.getId());
|
l.debug("!!!!!!!" + compare.getId());
|
||||||
l.debug(p.getType());
|
l.debug("!!!!!!!" + compare.getPortType());
|
||||||
l.debug(p.getPortNumber());
|
l.debug("!!!!!!!" + compare.getPortNumber());
|
||||||
l.debug(p.getCreateAt());
|
l.debug("!!!!!!!" + compare.getCreateDate());
|
||||||
l.debug(p.getUpdateAt());
|
l.debug("!!!!!!!" + compare.getUpdateDate());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,11 +78,11 @@ public class DiscoveryPortRepositoryTest {
|
||||||
|
|
||||||
List<ServiceScanHistory> h = new ArrayList<ServiceScanHistory>();
|
List<ServiceScanHistory> h = new ArrayList<ServiceScanHistory>();
|
||||||
byte [] a = {10,20,30,40,50};
|
byte [] a = {10,20,30,40,50};
|
||||||
h.add(new ServiceScanHistory(p,"testservice1", DirectionType.S,a, new Date()));
|
h.add(new ServiceScanHistory(p,"testservice1", DirectionType.Send,a, new Date()));
|
||||||
h.add(new ServiceScanHistory(p,"testservice2", DirectionType.R,a, new Date()));
|
h.add(new ServiceScanHistory(p,"testservice2", DirectionType.Recv,a, new Date()));
|
||||||
h.add(new ServiceScanHistory(p,"testservice3", DirectionType.S,a, new Date()));
|
h.add(new ServiceScanHistory(p,"testservice3", DirectionType.Send,a, new Date()));
|
||||||
h.add(new ServiceScanHistory(p,"testservice4", DirectionType.R,a, new Date()));
|
h.add(new ServiceScanHistory(p,"testservice4", DirectionType.Recv,a, new Date()));
|
||||||
h.add(new ServiceScanHistory(p,"testservice5", DirectionType.S,a, new Date()));
|
h.add(new ServiceScanHistory(p,"testservice5", DirectionType.Send,a, new Date()));
|
||||||
|
|
||||||
p.setHistories(h);
|
p.setHistories(h);
|
||||||
repo.save(p);
|
repo.save(p);
|
||||||
|
@ -93,5 +94,11 @@ public class DiscoveryPortRepositoryTest {
|
||||||
List<ServiceScanHistory> l2 = find.getHistories();
|
List<ServiceScanHistory> l2 = find.getHistories();
|
||||||
|
|
||||||
assertEquals(l1.size(), l2.size());
|
assertEquals(l1.size(), l2.size());
|
||||||
|
|
||||||
|
for (int i =0 ; i < l2.size() ; ++i) {
|
||||||
|
ServiceScanHistory s = l2.get(i);
|
||||||
|
l.debug(s.getDirection());
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user