Provide Best Programming Tutorials

AWS 账号架构设计

设计思想 随着在 AWS 上的工作负载不断增长和扩展,AWS Organizations 可以帮助用户集中管理用户的环境。不管是刚刚起步的新公司,还是一家大型企业,Organizations 都可以让用户集中管理账单、控制访问权限、合规性和安全性,并在用户的各个 AWS 账户间共享资源。 使用 AWS Organizations,用户可以根据业务需求自动创建帐户,创建帐户组,并应用针对这些组的管理策略。用户还可以通过对所有 AWS 帐户设置同一种支付方式来简化账单。通过与其他 AWS 服务整合,用户可以使用 Organizations 来指定公司帐户上的集中配置和资源共享。所有 AWS 客户都可以使用 AWS Organizations,且无需额外付费。 账号的结构图 主要组成部件的说明 SCP(Service Control Policies) 服务控制策略 (SCP) 是一种可用来管理用户的组织的策略。SCP…

Continue Reading

JUnit4中的@Rule

一、Rule简介 Rule是JUnit4中的新特性,它让我们可以扩展JUnit的功能,灵活地改变测试方法的行为。JUnit中用@Rule和@ClassRule两个注解来实现Rule扩展,这两个注解需要放在实现了TestRule借口的成员变量(@Rule)或者静态变量(@ClassRule)上。@Rule和@ClassRule的不同点是,@Rule是方法级别的,每个测试方法执行时都会调用被注解的Rule,而@ClassRule是类级别的,在执行一个测试类的时候只会调用一次被注解的Rule 二、JUnit内置Rule JUnit4中默认实现了一些常用的Rule: TemporaryFolder Rule 使用这个Rule可以创建一些临时目录或者文件,在一个测试方法结束之后,系统会自动清空他们。Java代码   //创建TemporaryFolder Rule //可以在构造方法上加入路径参数来指定临时目录,否则使用系统临时目录 @Rule public TemporaryFolder tempFolder = new TemporaryFolder(); @Test public void testTempFolderRule() throws IOException { //在系统的临时目录下创建文件或者目录,当测试方法执行完毕自动删除 tempFolder.newFile("test.txt"); tempFolder.newFolder("test"); } ExternalResource Rule…

Continue Reading

Overview of SAML

Security Assertion Markup Language (SAML) is a standard for logging users into applications based on their sessions in another context. This single sign-on (SSO) login standard has significant advantages over…

Continue Reading

How to convert object to JSON and vice versa in Java

Maven dependencies <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>2.10.0</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.8.11.1</version> </dependency> Convert Object to Json Core Logic package jsondemo; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import java.io.File; import java.io.IOException;…

Continue Reading

How to read/write from/to file in Java

Three ways to do this FileIutputStream and FileOutputStreamDataInputStream and DataOutputStreamBufferedInputStream and BufferedInputStream FileIutputStream and FileOutputStream package FileDemo; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; public class ReadAndWriteContentWithFile { public static void…

Continue Reading

Log4j2 Example

Import Maven dependency <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core --> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> <version>2.12.1</version> </dependency> <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api --> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-api</artifactId> <version>2.12.1</version> </dependency> Configuration File <?xml version="1.0" encoding="UTF-8"?> <Configuration status="INFO"> <Properties> <Property name="logPath">./</Property> <Property…

Continue Reading
Close Menu