小编Mic*_*tch的帖子

Java Spring Boot Test:如何从测试上下文中排除java配置类

我有一个带有弹簧启动的Java Web应用程序

运行测试时我需要排除一些Java配置文件:

测试配置(测试运行时需要包含):

@TestConfiguration
@PropertySource("classpath:otp-test.properties")
public class TestOTPConfig { }
Run Code Online (Sandbox Code Playgroud)

生产配置(测试运行时需要排除):

 @Configuration
 @PropertySource("classpath:otp.properties")
 public class OTPConfig { }
Run Code Online (Sandbox Code Playgroud)

测试类(使用显式配置类):

@RunWith(SpringRunner.class)
@SpringBootTest(classes = TestAMCApplicationConfig.class)
public class AuthUserServiceTest { .... }
Run Code Online (Sandbox Code Playgroud)

测试配置:

@TestConfiguration
@Import({ TestDataSourceConfig.class, TestMailConfiguration.class, TestOTPConfig.class })
@TestPropertySource("classpath:amc-test.properties")
public class TestAMCApplicationConfig extends AMCApplicationConfig { }
Run Code Online (Sandbox Code Playgroud)

也有课:

@SpringBootApplication
public class AMCApplication { }
Run Code Online (Sandbox Code Playgroud)

当测试运行时OTPConfig,我需要TestOTPConfig...

我该怎么做?

java testing spring spring-boot

13
推荐指数
6
解决办法
2万
查看次数

lea和offset之间的差异

ar db "Defference $"
Run Code Online (Sandbox Code Playgroud)

有什么区别

mov dx,offset ar
Run Code Online (Sandbox Code Playgroud)

lea dx,ar
Run Code Online (Sandbox Code Playgroud)

我认为两者都在做同样的工作,但这两者之间有什么区别

x86 assembly masm tasm

12
推荐指数
1
解决办法
1万
查看次数

如何使用GCC生成最小的BIOS hello world启动扇区,它可以在真实硬件上使用USB记忆棒?

我设法生成一个与QEMU 2.0.0 Ubuntu 14.04一起使用的最小引导扇区:

.code16
.global _start
_start:
    cli
    mov $msg, %si
    mov $0x0e, %ah
loop:
    lodsb
    or %al, %al
    jz halt
    int $0x10
    jmp loop
halt:
    hlt
msg:
    .asciz "hello world"
.org 510
.word 0xaa55
Run Code Online (Sandbox Code Playgroud)

编译:

as -o main.o main.S
ld --oformat binary -o main.img -Ttext 0x7C00 main.o
Run Code Online (Sandbox Code Playgroud)

这个例子可以在这个回购中找到:https://github.com/cirosantilli/x86-bare-metal-examples/tree/2b79ac21df801fbf4619d009411be6b9cd10e6e0/no-ld-script

一旦:

qemu -hda main.img
Run Code Online (Sandbox Code Playgroud)

hello world按预期在模拟器屏幕上显示.

但是,如果我尝试刻录到USB:

sudo dd if=main.img of=/dev/sdb
Run Code Online (Sandbox Code Playgroud)

然后将USB插入ThinkPad T400或T430,点击F12,然后选择我观察到的USB:

  • 一些启动消息很快显示出来
  • 然后屏幕变为空白,顶部只有一个下划线光标

我也用Ubuntu 14.04映像测试了相同的USB,它启动正常,因此USB工作正常.

我应该如何更改此示例,以便它将在硬件上启动并显示hello world消息?

Ubuntu图像和我创建的图像有什么区别?

这记录在哪里?

我已将sudo dmidecodeT400 …

x86 assembly qemu gnu-assembler bare-metal

12
推荐指数
1
解决办法
2402
查看次数

为什么我的CPU无法在HPC中保持最佳性能

我开发了一个高性能的 Cholesky分解程序,它应该在单个CPU上具有大约10.5 GFLOP的峰值性能(没有超线程).但是当我测试它的性能时,有一些我不明白的现象.在我的实验中,我通过增加矩阵维数N(从250到10000)来测量性能.

  • 在我的算法中,我已经应用了缓存(具有调整的阻塞因子),并且在计算期间总是以单位步长访问数据,因此缓存性能是最佳的; 消除了TLB和寻呼问题;
  • 我有8GB的可用RAM,实验期间的最大内存占用量低于800MB,因此没有交换;
  • 在实验过程中,没有像Web浏览器那样的资源需求过程同时运行.只有一些非常便宜的后台进程正在运行以记录CPU频率以及每2秒CPU温度数据.

对于任何NI测试,我都希望性能(在GFLOP中)应保持在10.5左右.但是,如第一张图所示,在实验中间观察到显着的性能下降.

CPU频率和CPU温度见第2和第3图.实验在400年代结束.实验开始时温度为51度,CPU忙时迅速升至72度.之后,它慢慢增长到78度的最高点.CPU频率基本稳定,温度升高时不下降.

所以,我的问题是:

  • 由于CPU频率没有下降,为什么性能会受到影响?
  • 温度究竟如何影响CPU性能?从72度到78度的增量真的会让事情变得更糟吗? 在此输入图像描述 在此输入图像描述 在此输入图像描述

CPU信息

System: Ubuntu 14.04 LTS
Laptop model: Lenovo-YOGA-3-Pro-1370
Processor: Intel Core M-5Y71 CPU @ 1.20 GHz * 2

Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                4
On-line CPU(s) list:   0,1
Off-line CPU(s) list:  2,3
Thread(s) per core:    1
Core(s) per socket:    2
Socket(s):             1
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 61
Stepping:              4
CPU MHz:               1474.484
BogoMIPS:              2799.91
Virtualisation: …
Run Code Online (Sandbox Code Playgroud)

x86 hpc matrix cpu-speed matrix-multiplication

12
推荐指数
1
解决办法
4302
查看次数

has-danger不再适用于Bootstrap v4 beta?

根据Bootstrap迁移指南:

将.has-error重命名为.has-danger.

但是,这似乎不起作用.边框和文字尚未着色.

例如:

<div class="form-group has-danger">
    <label class="form-control-label" for="inputDanger1">Input with danger</label>
    <input type="text" class="form-control form-control-danger" id="inputDanger1">
    <div class="form-control-feedback">Sorry, that username's taken. Try another?</div>
    <small class="form-text text-muted">Example help text that remains unchanged.</small>
</div>
Run Code Online (Sandbox Code Playgroud)

演示:

https://jsfiddle.net/uLa0spfm/

css css3 twitter-bootstrap bootstrap-4

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

Could someone please explain what this inline #define assembly is doing?

I'm an occasional C programmer. I've come across this bit of inline assembly code in a Turbo C program

#define ADC(dst,src)    { asm MOV AX, dst;  asm ADD AX, src;  \
              asm ADC AX, 0;    asm MOV dst, AX; }
Run Code Online (Sandbox Code Playgroud)

dst and src are both unsigned 16-bit integers.

It won't compile in GNU C++. Could someone please explain what it's doing? TIA!

x86 assembly gcc turbo-c carryflag

12
推荐指数
2
解决办法
648
查看次数

启动接收器不工作

表现:

         <application android:icon="@drawable/icon" android:label="@string/app_name">
            <activity android:name=".AlarmActivity"
                      android:label="@string/app_name">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
                </intent-filter>
            </activity>
            <receiver android:name="CallReciver">
                <intent-filter>
                    <action android:name="android.intent.action.PHONE_STATE">  

</action>
                </intent-filter>
            </receiver>
            <receiver android:name=".SmsReceiver"> 
               <intent-filter android:priority="1000">
                    <action android:name=
                        "android.provider.Telephony.SMS_RECEIVED" /> 
                </intent-filter> 
            </receiver>
             <receiver android:name=".OnBootReceiver">
          <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
          </intent-filter>
        </receiver>
            <service
                android:enabled="true"
                android:name=".AlarmService">
            </service>
        </application>
         <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED">
         </uses-permission>
        <uses-permission android:name="android.permission.READ_PHONE_STATE">
        </uses-permission>
        <uses-permission android:name="android.permission.WRITE_SMS">
        </uses-permission>
       <uses-permission android:name="android.permission.READ_SMS">
        </uses-permission>
       <uses-permission android:name="android.permission.SEND_SMS">
        </uses-permission>
        <uses-permission android:name="android.permission.RECEIVE_SMS">
        </uses-permission>
        <uses-permission android:name="android.permission.INTERNET">
        </uses-permission>
Run Code Online (Sandbox Code Playgroud)

接收器:

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;

public class OnBootReceiver extends …
Run Code Online (Sandbox Code Playgroud)

boot android broadcastreceiver

11
推荐指数
2
解决办法
2万
查看次数

C代码中堆栈的三重故障

我正在为学习目的编写一个玩具内核,我遇到了一些麻烦.我做了一个简单的引导加载程序,从软盘加载一个段(用32位代码写入),然后引导加载程序启用A20门并打开保护模式.如果我用汇编程序写它,我可以跳到32位代码,但是如果我用C语言写它,我会得到一个三重错误.当我反汇编C代码时,我可以看到前两条指令涉及设置一个新的堆栈帧.这是工作ASM代码和失败的C代码之间的关键区别.我使用NASM v2.10.05作为ASM代码,使用来自DJGPP 4.72集合的GCC作为C代码.

这是引导加载程序代码:

org 7c00h
BITS 16

entry:
mov [drive], dl         ;Save the current drive


cli
mov ax,cs               ; Setup segment registers
mov ds,ax               ; Make DS correct
mov ss,ax               ; Make SS correct        

mov bp,0fffeh
mov sp,0fffeh           ;Setup a temporary stack
sti

;Set video mode to text
;===================
mov ah, 0
mov al, 3
int 10h
;===================

;Set current page to 0
;==================
mov ah, 5
mov al, 0
int 10h
;==================

;Load the sector
;=============
call load_image …
Run Code Online (Sandbox Code Playgroud)

x86 assembly stack gcc osdev

11
推荐指数
1
解决办法
620
查看次数

简单地测试Spring Boot Security

我正在努力测试受Spring Security保护的URL的访问控制.

配置如下所示:

    http
            .authorizeRequests()
            .antMatchers("/api/user/**", "/user").authenticated()
            .antMatchers("/api/admin/**", "/templates/admin/**", "/admin/**").hasAuthority("ADMIN")
            .anyRequest().permitAll();
Run Code Online (Sandbox Code Playgroud)

测试类看起来像这样:

package com.kubukoz.myapp;

import com.kubukoz.myapp.config.WebSecurityConfig;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.security.web.FilterChainProxy;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;

import javax.transaction.Transactional;

import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;


@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = {MyApplication.class, WebSecurityConfig.class})
@WebAppConfiguration
@TransactionConfiguration(defaultRollback = true)
@Transactional(rollbackOn = Exception.class)
public class MyApplicationTests {

    @Autowired
    private WebApplicationContext context;
    private MockMvc mockMvc;
    @Autowired
    private FilterChainProxy filterChainProxy;

    @Before
    public void …
Run Code Online (Sandbox Code Playgroud)

java security testing spring spring-boot

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

Nasm - 符号`printf'导致R_X86_64_PC32重定位溢出

我试图在nasm中创建一个应该显示该字母的简单程序a.然而,它给了我一个Segfault并说:

./a.out: Symbol `printf' causes overflow in R_X86_64_PC32 relocation
Segmentation fault (core dumped)
Run Code Online (Sandbox Code Playgroud)

基本上,我试图将值0x61(字母a的十六进制)移动到内存地址1234,然后将其作为参数传递给printf.这是我的确切代码:

extern printf
section .text
global main
main:
push rbp
mov rax,0
mov qword [1234], 0x61 ; move 0x61 into address 1234
mov rdi, qword [1234] ; mov address 1234 into rdi
call printf ; should print the letter a
pop rbp
mov rax,0
ret
Run Code Online (Sandbox Code Playgroud)

我正在运行Linux x86_64

linux gcc x86-64 nasm segmentation-fault

11
推荐指数
2
解决办法
5462
查看次数